ROSE  0.11.87.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue Class Reference

Description

Type of values manipulated by the MultiSemantics domain.

A multi-semantic value is a set of values, one from each of the subdomains, and a bit vector that indicates which values are valid. The bit vector is accessed by the RiscOperators and new values are created by those operators with appropriate validities, but the MultiSemantics domain doesn't otherwise modify the bit vector–that's up to the user-defined, inter-operation callbacks.

Individual sub-domain values can be queried from a multi-domain value with get_subvalue() using the ID returned by add_subdomain() when the sub-domain's RiscOperators were added to the multi-domain's RiscOperators.

Definition at line 83 of file MultiSemantics.h.

#include <Rose/BinaryAnalysis/InstructionSemantics2/MultiSemantics.h>

Inheritance diagram for Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue:
Collaboration graph
[legend]

Public Types

using Super = BaseSemantics::SValue
 Base type. More...
 
using Ptr = SValuePtr
 Shared-ownership pointer. More...
 
- Public Types inherited from Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue
using Ptr = SValuePtr
 Shared-ownership pointer for an SValue object. More...
 

Public Member Functions

virtual BaseSemantics::SValuePtr bottom_ (size_t nbits) const override
 Data-flow bottom value. More...
 
virtual BaseSemantics::SValuePtr undefined_ (size_t nbits) const override
 Create a new undefined MultiSemantics value. More...
 
virtual BaseSemantics::SValuePtr unspecified_ (size_t nbits) const override
 Create a new unspecified MultiSemantics value. More...
 
virtual BaseSemantics::SValuePtr number_ (size_t nbits, uint64_t number) const override
 Create a MultiSemantics value holding a concrete value. More...
 
virtual SValuePtr create_empty (size_t nbits) const
 Create a new MultiSemantics value with no valid subvalues. More...
 
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. More...
 
virtual Sawyer::Optional< BaseSemantics::SValuePtrcreateOptionalMerge (const BaseSemantics::SValuePtr &other, const BaseSemantics::MergerPtr &, const SmtSolverPtr &) const override
 Possibly create a new value by merging two existing values. More...
 
virtual bool isBottom () const override
 Determines whether a value is a data-flow bottom. More...
 
virtual void print (std::ostream &, BaseSemantics::Formatter &) const override
 Print a value to a stream using default format. More...
 
virtual void hash (Combinatorics::Hasher &) const override
 Hash this semantic value. More...
 
virtual bool may_equal (const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const override
 Determines if two multidomain values might be equal. More...
 
virtual bool must_equal (const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const override
 Determines if two multidomain values must be equal. More...
 
virtual void set_width (size_t nbits) override
 Virtual API. More...
 
virtual bool is_number () const override
 Determines if the value is a concrete number. More...
 
virtual uint64_t get_number () const override
 Virtual API. More...
 
virtual bool is_valid (size_t idx) const
 Returns true if a subdomain value is valid. More...
 
virtual void invalidate (size_t idx)
 Removes a subdomain value and marks it as invalid. More...
 
virtual BaseSemantics::SValuePtr get_subvalue (size_t idx) const
 Return a subdomain value. More...
 
virtual void set_subvalue (size_t idx, const BaseSemantics::SValuePtr &value)
 Insert a subdomain value. More...
 
- Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue
virtual SValuePtr boolean_ (bool value) const
 Create a new, Boolean value. More...
 
SValuePtr createMerged (const SValuePtr &other, const MergerPtr &merger, const SmtSolverPtr &solver) const
 Create a new value by merging two existing values. More...
 
size_t nBits () const
 Property: value width. More...
 
bool isConcrete () const
 Determines if the value is a concrete number. More...
 
Sawyer::Optional< uint64_t > toUnsigned () const
 Converts a concrete value to a native unsigned integer. More...
 
Sawyer::Optional< int64_t > toSigned () const
 Converts a concrete value to a native signed integer. More...
 
bool mustEqual (const SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
 Tests two values for equality. More...
 
bool mayEqual (const SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const
 Tests two values for possible equality. More...
 
bool isTrue () const
 Returns true if concrete non-zero. More...
 
bool isFalse () const
 Returns true if concrete zero. More...
 
std::string comment () const
 Property: Comment. More...
 
void comment (const std::string &) const
 Property: Comment. More...
 
void print (std::ostream &) const
 Print a value to a stream using default format. More...
 
WithFormatter with_format (Formatter &fmt)
 Used for printing values with formatting. More...
 
WithFormatter operator+ (Formatter &fmt)
 Used for printing values with formatting. More...
 
WithFormatter operator+ (const std::string &linePrefix)
 Used for printing values with formatting. More...
 
virtual size_t get_width () const
 Virtual API. More...
 
virtual std::string get_comment () const
 Some subclasses support the ability to add comments to values. More...
 
virtual void set_comment (const std::string &) const
 Some subclasses support the ability to add comments to values. More...
 
- Public Member Functions inherited from Sawyer::SharedObject
 SharedObject ()
 Default constructor. More...
 
 SharedObject (const SharedObject &)
 Copy constructor. More...
 
virtual ~SharedObject ()
 Virtual destructor. More...
 
SharedObjectoperator= (const SharedObject &)
 Assignment. More...
 
- Public Member Functions inherited from Sawyer::SharedFromThis< SValue >
SharedPointer< SValue > sharedFromThis ()
 Create a shared pointer from this. More...
 
SharedPointer< const SValue > sharedFromThis () const
 Create a shared pointer from this. More...
 

Static Public Member Functions

static SValuePtr instance ()
 Construct a prototypical value. More...
 
static SValuePtr promote (const BaseSemantics::SValuePtr &v)
 Promote a base value to a MultiSemantics value. More...
 
- Static Public Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue
static SValuePtr promote (const SValuePtr &x)
 
- Static Public Member Functions inherited from Sawyer::SmallObject
static SynchronizedPoolAllocatorpoolAllocator ()
 Return the pool allocator for this class. More...
 
static void * operator new (size_t size)
 
static void operator delete (void *ptr, size_t size)
 

Protected Types

typedef std::vector< BaseSemantics::SValuePtrSubvalues
 

Protected Member Functions

 SValue (size_t nbits)
 
 SValue (const SValue &other)
 
void init (const SValue &other)
 
- Protected Member Functions inherited from Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue
 SValue (size_t nbits)
 
 SValue (const SValue &other)
 

Protected Attributes

Subvalues subvalues
 
- Protected Attributes inherited from Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue
size_t width
 

Member Typedef Documentation

Base type.

Definition at line 86 of file MultiSemantics.h.

Shared-ownership pointer.

Definition at line 89 of file MultiSemantics.h.

Member Function Documentation

static SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::instance ( )
inlinestatic

Construct a prototypical value.

Prototypical values are only used for their virtual constructors.

Definition at line 111 of file MultiSemantics.h.

Referenced by Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::RiscOperators::instance().

static SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::promote ( const BaseSemantics::SValuePtr v)
inlinestatic

Promote a base value to a MultiSemantics value.

The value v must have a MultiSemantics::SValue dynamic type.

Definition at line 116 of file MultiSemantics.h.

References Sawyer::SharedPointer< T >::dynamicCast().

Referenced by Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::RiscOperators::svalue_empty().

virtual BaseSemantics::SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::bottom_ ( size_t  nBits) const
overridevirtual

Data-flow bottom value.

Returns a new value that represents bottom in a data-flow analysis. If a semantic domain can represent a bottom value then the isBottom predicate is true when invoked on this method's return value. If a semantic domain cannot support a bottom value, then it may return some other value.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual BaseSemantics::SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::undefined_ ( size_t  nbits) const
overridevirtual

Create a new undefined MultiSemantics value.

The returned value is constructed by calling the virtual undefined_() for each subdomain value in "this". If you want a multidomain value that has no valid subvalues, then use the create_empty() method instead.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual BaseSemantics::SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::unspecified_ ( size_t  nbits) const
overridevirtual

Create a new unspecified MultiSemantics value.

The returned value is constructed by calling the virtual unspecified_() for each subdomain value in "this". If you want a multidomain value that has no valid subvalues, then use the create_empty() method instead.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual BaseSemantics::SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::number_ ( size_t  nbits,
uint64_t  number 
) const
overridevirtual

Create a MultiSemantics value holding a concrete value.

The returned value is constructed by calling the virtual number_() method for each subdomain value in "this".

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::create_empty ( size_t  nbits) const
inlinevirtual

Create a new MultiSemantics value with no valid subvalues.

The caller will probably construct a value iteratively by invoking set_subvalue() one or more times.

Definition at line 144 of file MultiSemantics.h.

virtual BaseSemantics::SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::copy ( size_t  new_width = 0) const
inlineoverridevirtual

Create a new value from an existing value, changing the width if new_width is non-zero.

Increasing the width logically adds zero bits to the most significant side of the value; decreasing the width logically removes bits from the most significant side of the value.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

Definition at line 148 of file MultiSemantics.h.

virtual Sawyer::Optional<BaseSemantics::SValuePtr> Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::createOptionalMerge ( const BaseSemantics::SValuePtr other,
const BaseSemantics::MergerPtr merger,
const SmtSolverPtr solver 
) const
overridevirtual

Possibly create a new value by merging two existing values.

This method optionally returns a new semantic value as the data-flow merge of this and other. If the two inputs are "equal" in some sense of the dataflow implementation then nothing is returned, otherwise a new value is returned. Typical usage is like this:

if (SValuePtr merged = v1->createOptionalMerge(v2).orDefault()) {
std::cout <<"v1 and v2 were merged to " <<*merged <<"\n";
} else {
std::cout <<"no merge is necessary\n";
}
or
@code
SValuePtr merge;
if (v1->createOptionalMerge(v2).assignTo(merged)) {
std::cout <<"v1 and v2 were merged to " <<*merged <<"\n";
} else {
std::cout <<"v1 and v2 are equal in some sense (no merge necessary)\n";
}

If you always want a copy regardless of whether the merge is necessary, then use the createMerged convenience function instead.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual bool Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::isBottom ( ) const
overridevirtual

Determines whether a value is a data-flow bottom.

Returns true if this value represents a bottom value for data-flow analysis. Any RiscOperation performed on an operand whose isBottom predicate returns true will itself return a bottom value. This includes operations like "xor x x" which would normally return zero.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::print ( std::ostream &  ,
BaseSemantics::Formatter  
) const
overridevirtual

Print a value to a stream using default format.

The value will normally occupy a single line and not contain leading space or line termination. See also, with_format().

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::hash ( Combinatorics::Hasher ) const
overridevirtual

Hash this semantic value.

Hashes the value by appending it to the specified hasher.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual bool Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::may_equal ( const BaseSemantics::SValuePtr other,
const SmtSolverPtr solver = SmtSolverPtr() 
) const
overridevirtual

Determines if two multidomain values might be equal.

Two multidomain values are equal if, for any subdomain for which both values are valid, they are equal in the subdomain.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual bool Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::must_equal ( const BaseSemantics::SValuePtr other,
const SmtSolverPtr solver = SmtSolverPtr() 
) const
overridevirtual

Determines if two multidomain values must be equal.

Two multidomain values are equal if and only if there is at least one subdomain where both values are valid, and for all subdomains where both values are valid, their must_equal() relationship is satisfied.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::set_width ( size_t  nbits)
overridevirtual
virtual bool Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::is_number ( ) const
overridevirtual

Determines if the value is a concrete number.

In the MultiSemantics domain, a value is a concrete number if and only if it has at least one valid subdomain value and all valid subdomain values are concrete numbers, and all are the same concrete number.

Implements Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue.

virtual uint64_t Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::get_number ( ) const
overridevirtual
virtual bool Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::is_valid ( size_t  idx) const
inlinevirtual

Returns true if a subdomain value is valid.

A subdomain value is valid if the specified index has a non-null SValue pointer. It is permissible to call this with an index that is out of range (false is returned in that case).

Definition at line 194 of file MultiSemantics.h.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::invalidate ( size_t  idx)
virtual

Removes a subdomain value and marks it as invalid.

It is permissible to call this with an index that does not correspond to a valid subdomain value.

virtual BaseSemantics::SValuePtr Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::get_subvalue ( size_t  idx) const
inlinevirtual

Return a subdomain value.

The subdomain must be valid according to is_valid().

Definition at line 203 of file MultiSemantics.h.

virtual void Rose::BinaryAnalysis::InstructionSemantics2::MultiSemantics::SValue::set_subvalue ( size_t  idx,
const BaseSemantics::SValuePtr value 
)
inlinevirtual

Insert a subdomain value.

The specified value is inserted at the specified index. No attempt is made to validate whether the value has a valid dynamic type for that slot. If the value is not a null pointer, then is_valid() will return true after this call.

Definition at line 211 of file MultiSemantics.h.

References Rose::BinaryAnalysis::InstructionSemantics2::BaseSemantics::SValue::nBits().


The documentation for this class was generated from the following file: