ROSE  0.9.9.109
Classes | Typedefs
Rose::BinaryAnalysis::InstructionSemantics2::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
const size_t AlphaID = 0, BetaID = 1; //probably part of the constructor
if (is_active(AlphaID) && is_active(BetaID)) {
clear_active(BetaID);
set_active(BetaID);
Beta::SValuePtr beta_result = compute_from_alpha(retval.get_subvalue(AlphaID));
result.set_subvalue(BetaID, beta_result);
return result;
}
return MultiSemantics::RiscOperators(a_, b_);
}
};

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. More...
 
typedef void RegisterState
 
typedef boost::shared_ptr< void > RegisterStatePtr
 Shared-ownership pointer to a multi-semantics register state. More...
 
typedef void MemoryState
 
typedef boost::shared_ptr< void > MemoryStatePtr
 Shared-ownership pointer to a multi-semantics memory state. More...
 
typedef void State
 
typedef boost::shared_ptr< void > StatePtr
 Shared-ownership pointer to a multi-semantics state. More...
 
typedef boost::shared_ptr< class RiscOperatorsRiscOperatorsPtr
 Shared-ownership pointer to multi-semantics RISC operators. More...
 

Typedef Documentation

Shared-ownership pointer to a multi-semantic value.

See Shared ownership.

Definition at line 70 of file MultiSemantics2.h.

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

See Shared ownership.

Definition at line 209 of file MultiSemantics2.h.

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

See Shared ownership.

Definition at line 218 of file MultiSemantics2.h.

Shared-ownership pointer to a multi-semantics state.

See Shared ownership.

Definition at line 227 of file MultiSemantics2.h.

Shared-ownership pointer to multi-semantics RISC operators.

See Shared ownership.

Definition at line 234 of file MultiSemantics2.h.