ROSE 0.11.145.147
Classes | Typedefs
Rose::BinaryAnalysis::InstructionSemantics::MultiSemantics Namespace Reference

Description

Semantic domain composed of subdomains.

The MultiSemantics semantic domain is a pseudo domain composed of one or more subdomains. Each of the RISC operations implemented in this policy invokes the operation in each of the enabled subdomains. The type of values manipulated by the MultiSemantics domain are the union of the values from each of the subdomains. One could accomplish the same thing by instantiating multiple instruction semantics objects and calling each one for each instruction. However, using this MultiSemantics domain is cleaner and easier to specialize.

A multi-domain is created by instantiating all the subdomain RiscOperators and adding them one by one to the multi-domain RiscOperators object via its add_subdomain() method. Each call to add_subdomain() returns an ID number for the subdomain, by which the subdomain's RiscOperators and SValue objects can be accessed given a multi-domain RiscOperators or SValue object.

A sub-domain can be marked as active or inactive. When the a multi-domain RISC operation is called, the same operation will be invoked in each of the active sub-domains (provided the operation's inputs are valid for that sub-domain). If the operation returns a multi-value (as most do), then the sub-values corresponding to called sub-domains will be marked valid and the other sub-values are marked invalid.

Using a multi-domain directly is not all that interesting. Where the real convenience comes is in specializing the multi-domain to do things like convert values from one domain to another. For example, consider two semantic domains called Alpha and Beta implemented operating on values of type AlphaValue and BetaValue. Assume that for some reason, and ADD operation in Beta is expensive and that a BetaValue can be constructed from an AlphaValue. Therefore, it is more efficient to skip the ADD operation in Beta and instead compute the Beta sum from the Alpha sum. One does that by subclassing the MultiDomain::RiscOperators and overriding its add() method. Here's the basic idea, sans error handling, etc.:

class MyDomain: public MultiSemantics::RiscOperators {
public:
// the usual virtual constructors go here...
public:
SValuePtr a = SValue::promote(a_); //promote from BaseSemantics to MultiSemantics SValue
SValuePtr b = SValue::promote(b_);
const size_t AlphaID = 0, BetaID = 1; //probably part of the constructor
if (is_active(AlphaID) && is_active(BetaID)) {
clear_active(BetaID);
SValuePtr result = SValue::promote(MultiSemantics::RiscOperators::add(a_, b_));
set_active(BetaID);
Beta::SValuePtr beta_result = compute_from_alpha(retval.get_subvalue(AlphaID));
result.set_subvalue(BetaID, beta_result);
return result;
}
}
};
Defines RISC operators for the MultiSemantics domain.

Classes

class  Formatter
 Helps printing multidomain values by allowing the user to specify a name for each subdomain. More...
 
class  RiscOperators
 Defines RISC operators for the MultiSemantics domain. More...
 
class  SValue
 Type of values manipulated by the MultiSemantics domain. More...
 

Typedefs

typedef Sawyer::SharedPointer< class SValueSValuePtr
 Shared-ownership pointer to a multi-semantic value.
 
typedef void RegisterState
 
typedef boost::shared_ptr< void > RegisterStatePtr
 Shared-ownership pointer to a multi-semantics register state.
 
typedef void MemoryState
 
typedef boost::shared_ptr< void > MemoryStatePtr
 Shared-ownership pointer to a multi-semantics memory state.
 
typedef void State
 
typedef boost::shared_ptr< void > StatePtr
 Shared-ownership pointer to a multi-semantics state.
 
typedef boost::shared_ptr< class RiscOperatorsRiscOperatorsPtr
 Shared-ownership pointer to multi-semantics RISC operators.
 

Typedef Documentation

◆ SValuePtr

Shared-ownership pointer to a multi-semantic value.

Definition at line 73 of file MultiSemantics.h.

◆ RegisterState

typedef void Rose::BinaryAnalysis::InstructionSemantics::MultiSemantics::RegisterState

Definition at line 200 of file MultiSemantics.h.

◆ RegisterStatePtr

Shared-ownership pointer to a multi-semantics register state.

Definition at line 203 of file MultiSemantics.h.

◆ MemoryState

typedef void Rose::BinaryAnalysis::InstructionSemantics::MultiSemantics::MemoryState

Definition at line 209 of file MultiSemantics.h.

◆ MemoryStatePtr

Shared-ownership pointer to a multi-semantics memory state.

Definition at line 212 of file MultiSemantics.h.

◆ State

typedef void Rose::BinaryAnalysis::InstructionSemantics::MultiSemantics::State

Definition at line 218 of file MultiSemantics.h.

◆ StatePtr

Shared-ownership pointer to a multi-semantics state.

Definition at line 221 of file MultiSemantics.h.

◆ RiscOperatorsPtr

Shared-ownership pointer to multi-semantics RISC operators.

Definition at line 228 of file MultiSemantics.h.