Ghidra Decompiler Analysis Engine
Public Member Functions | Static Public Member Functions | List of all members
OpBehavior Class Reference

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

#include <opbehavior.hh>

Inherited by 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, OpBehaviorPopcount, and 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...
 

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

◆ 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

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

Emulate the unary op-code on an input value.

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

Reimplemented in OpBehaviorPopcount, OpBehaviorFloatRound, OpBehaviorFloatFloor, OpBehaviorFloatCeil, OpBehaviorFloatTrunc, OpBehaviorFloatFloat2Float, OpBehaviorFloatInt2Float, OpBehaviorFloatSqrt, OpBehaviorFloatAbs, OpBehaviorFloatNeg, OpBehaviorFloatNan, OpBehaviorBoolNegate, OpBehaviorIntNegate, OpBehaviorInt2Comp, OpBehaviorIntSext, OpBehaviorIntZext, and OpBehaviorCopy.

◆ 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

◆ 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

◆ 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

◆ 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.

◆ 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.

◆ registerInstructions()

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

Build all pcode behaviors.

This routine generates a vector of OpBehavior objects indexed by opcode

Parameters
instis the vector of behaviors to be filled
transis the translator object needed by the floating point behaviors

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