decompiler  1.0.0
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
OpBehavior Class Reference

Class encapsulating the action/behavior of specific pcode opcodes. More...

#include <opbehavior.hh>

Inheritance diagram for OpBehavior:
OpBehaviorBoolAnd OpBehaviorBoolNegate OpBehaviorBoolOr OpBehaviorBoolXor OpBehaviorCopy OpBehaviorEqual OpBehaviorFloatAbs OpBehaviorFloatAdd OpBehaviorFloatCeil OpBehaviorFloatDiv OpBehaviorFloatEqual OpBehaviorFloatFloat2Float OpBehaviorFloatFloor OpBehaviorFloatInt2Float OpBehaviorFloatLess OpBehaviorFloatLessEqual OpBehaviorFloatMult OpBehaviorFloatNan OpBehaviorFloatNeg OpBehaviorFloatNotEqual OpBehaviorFloatRound OpBehaviorFloatSqrt OpBehaviorFloatSub OpBehaviorFloatTrunc OpBehaviorInt2Comp OpBehaviorIntAdd OpBehaviorIntAnd OpBehaviorIntCarry OpBehaviorIntDiv OpBehaviorIntLeft OpBehaviorIntLess OpBehaviorIntLessEqual OpBehaviorIntMult OpBehaviorIntNegate OpBehaviorIntOr OpBehaviorIntRem OpBehaviorIntRight OpBehaviorIntSborrow OpBehaviorIntScarry OpBehaviorIntSdiv OpBehaviorIntSext OpBehaviorIntSless OpBehaviorIntSlessEqual OpBehaviorIntSrem OpBehaviorIntSright OpBehaviorIntSub OpBehaviorIntXor OpBehaviorIntZext OpBehaviorNotEqual OpBehaviorPiece OpBehaviorSubpiece

Public Member Functions

 OpBehavior (OpCode opc, bool isun)
 A behavior constructor. More...
 
 OpBehavior (OpCode opc, bool isun, bool isspec)
 A special behavior constructor. More...
 
OpCode getOpcode (void) const
 Get the opcode for this pcode operation. More...
 
bool isSpecial (void) const
 Check if this is a special operator. More...
 
bool isUnary (void) const
 Check if operator is unary. More...
 
virtual uintb evaluateUnary (int4 sizeout, int4 sizein, uintb in1) const
 Emulate the unary op-code on an input value. More...
 
virtual uintb evaluateBinary (int4 sizeout, int4 sizein, uintb in1, uintb in2) const
 Emulate the binary op-code on input values. More...
 
virtual uintb recoverInputBinary (int4 slot, int4 sizeout, uintb out, int4 sizein, uintb in) const
 Reverse the binary op-code operation, recovering an input value. More...
 
virtual uintb recoverInputUnary (int4 sizeout, uintb out, int4 sizein) const
 Reverse the unary op-code operation, recovering the input value. More...
 

Static Public Member Functions

static void registerInstructions (vector< OpBehavior * > &inst, const Translate *trans)
 Build all pcode behaviors. More...
 

Private Attributes

OpCode opcode
 the internal enumeration for pcode types
 
bool isunary
 true= use unary interfaces, false = use binary
 
bool isspecial
 Is op not a normal unary or binary op.
 

Detailed Description

Class encapsulating the action/behavior of specific pcode opcodes.

At the lowest level, a pcode op is one of a small set of opcodes that operate on varnodes (address space, offset, size). Classes derived from this base class encapsulate this basic behavior for each possible opcode. These classes describe the most basic behaviors and include:

Constructor & Destructor Documentation

◆ OpBehavior() [1/2]

OpBehavior::OpBehavior ( OpCode  opc,
bool  isun 
)
inline

A behavior constructor.

This kind of OpBehavior is associated with a particular opcode and is either unary or binary

Parameters
opcis the opcode of the behavior
isunis true if the behavior is unary, false if binary

References isspecial, isunary, and opcode.

Referenced by registerInstructions().

◆ OpBehavior() [2/2]

OpBehavior::OpBehavior ( OpCode  opc,
bool  isun,
bool  isspec 
)
inline

A special behavior constructor.

This kind of OpBehavior can be set to special, if it neither unary or binary.

Parameters
opcis the opcode of the behavior
isunis true if the behavior is unary
isspecis true if the behavior is neither unary or binary

References isspecial, isunary, and opcode.

Member Function Documentation

◆ evaluateBinary()

uintb OpBehavior::evaluateBinary ( int4  sizeout,
int4  sizein,
uintb  in1,
uintb  in2 
) const
virtual

◆ evaluateUnary()

uintb OpBehavior::evaluateUnary ( int4  sizeout,
int4  sizein,
uintb  in1 
) const
virtual

◆ getOpcode()

OpCode OpBehavior::getOpcode ( void  ) const
inline

Get the opcode for this pcode operation.

There is an internal enumeration value for each type of pcode operation. This routine returns that value.

Returns
the opcode value

References opcode.

Referenced by Emulate::executeCurrentOp(), and PcodeOpRaw::getOpcode().

◆ isSpecial()

bool OpBehavior::isSpecial ( void  ) const
inline

Check if this is a special operator.

If this function returns false, the operation is a normal unary or binary operation which can be evaluated calling evaluateBinary() or evaluateUnary(). Otherwise, the operation requires special handling to emulate properly

References isspecial.

Referenced by Emulate::executeCurrentOp().

◆ isUnary()

bool OpBehavior::isUnary ( void  ) const
inline

Check if operator is unary.

The operated can either be evaluated as unary or binary

Returns
true if the operator is unary

References isunary.

Referenced by Emulate::executeCurrentOp().

◆ recoverInputBinary()

uintb OpBehavior::recoverInputBinary ( int4  slot,
int4  sizeout,
uintb  out,
int4  sizein,
uintb  in 
) const
virtual

Reverse the binary op-code operation, recovering an input value.

If the output value and one of the input values is known, recover the value of the other input.

Parameters
slotis the input slot to recover
sizeoutis the size of the output in bytes
outis the output value
sizeinis the size of the inputs in bytes
inis the known input value
Returns
the input value corresponding to the slot

Reimplemented in OpBehaviorIntSright, OpBehaviorIntRight, OpBehaviorIntLeft, OpBehaviorIntSub, and OpBehaviorIntAdd.

Referenced by TypeOp::recoverInputBinary(), OpBehaviorIntLeft::recoverInputBinary(), OpBehaviorIntRight::recoverInputBinary(), and OpBehaviorIntSright::recoverInputBinary().

◆ recoverInputUnary()

uintb OpBehavior::recoverInputUnary ( int4  sizeout,
uintb  out,
int4  sizein 
) const
virtual

Reverse the unary op-code operation, recovering the input value.

If the output value is known, recover the input value.

Parameters
sizeoutis the size of the output in bytes
outis the output value
sizeinis the size of the input in bytes
Returns
the input value

Reimplemented in OpBehaviorIntSext, OpBehaviorIntZext, and OpBehaviorCopy.

Referenced by TypeOp::recoverInputUnary().

◆ registerInstructions()

void OpBehavior::registerInstructions ( vector< OpBehavior * > &  inst,
const Translate trans 
)
static

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