decompiler
1.0.0
|
Class encapsulating the action/behavior of specific pcode opcodes. More...
#include <opbehavior.hh>
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. | |
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:
|
inline |
A behavior constructor.
This kind of OpBehavior is associated with a particular opcode and is either unary or binary
opc | is the opcode of the behavior |
isun | is true if the behavior is unary, false if binary |
Referenced by registerInstructions().
|
inline |
A special behavior constructor.
This kind of OpBehavior can be set to special, if it neither unary or binary.
opc | is the opcode of the behavior |
isun | is true if the behavior is unary |
isspec | is true if the behavior is neither unary or binary |
|
virtual |
Emulate the binary op-code on input values.
sizeout | is the size of the output in bytes |
sizein | is the size of the inputs in bytes |
in1 | is the first input value |
in2 | is the second input value |
Reimplemented in OpBehaviorSubpiece, OpBehaviorPiece, OpBehaviorFloatSub, OpBehaviorFloatMult, OpBehaviorFloatDiv, OpBehaviorFloatAdd, OpBehaviorFloatLessEqual, OpBehaviorFloatLess, OpBehaviorFloatNotEqual, OpBehaviorFloatEqual, OpBehaviorBoolOr, OpBehaviorBoolAnd, OpBehaviorBoolXor, OpBehaviorIntSrem, OpBehaviorIntRem, OpBehaviorIntSdiv, OpBehaviorIntDiv, OpBehaviorIntMult, OpBehaviorIntSright, OpBehaviorIntRight, OpBehaviorIntLeft, OpBehaviorIntOr, OpBehaviorIntAnd, OpBehaviorIntXor, OpBehaviorIntSborrow, OpBehaviorIntScarry, OpBehaviorIntCarry, OpBehaviorIntSub, OpBehaviorIntAdd, OpBehaviorIntLessEqual, OpBehaviorIntLess, OpBehaviorIntSlessEqual, OpBehaviorIntSless, OpBehaviorNotEqual, and OpBehaviorEqual.
References get_opname(), and opcode.
Referenced by TypeOp::evaluateBinary(), OpBehaviorFloatEqual::evaluateBinary(), OpBehaviorFloatNotEqual::evaluateBinary(), OpBehaviorFloatLess::evaluateBinary(), OpBehaviorFloatLessEqual::evaluateBinary(), OpBehaviorFloatAdd::evaluateBinary(), OpBehaviorFloatDiv::evaluateBinary(), OpBehaviorFloatMult::evaluateBinary(), OpBehaviorFloatSub::evaluateBinary(), EmulatePcodeOp::executeBinary(), and EmulateSnippet::executeBinary().
|
virtual |
Emulate the unary op-code on an input value.
sizeout | is the size of the output in bytes |
sizein | is the size of the input in bytes |
in1 | is the input value |
Reimplemented in OpBehaviorPopcount, OpBehaviorFloatRound, OpBehaviorFloatFloor, OpBehaviorFloatCeil, OpBehaviorFloatTrunc, OpBehaviorFloatFloat2Float, OpBehaviorFloatInt2Float, OpBehaviorFloatSqrt, OpBehaviorFloatAbs, OpBehaviorFloatNeg, OpBehaviorFloatNan, OpBehaviorBoolNegate, OpBehaviorIntNegate, OpBehaviorInt2Comp, OpBehaviorIntSext, OpBehaviorIntZext, and OpBehaviorCopy.
References get_opname(), and opcode.
Referenced by TypeOp::evaluateUnary(), OpBehaviorFloatNan::evaluateUnary(), OpBehaviorFloatNeg::evaluateUnary(), OpBehaviorFloatAbs::evaluateUnary(), OpBehaviorFloatSqrt::evaluateUnary(), OpBehaviorFloatInt2Float::evaluateUnary(), OpBehaviorFloatFloat2Float::evaluateUnary(), OpBehaviorFloatTrunc::evaluateUnary(), OpBehaviorFloatCeil::evaluateUnary(), OpBehaviorFloatFloor::evaluateUnary(), OpBehaviorFloatRound::evaluateUnary(), EmulatePcodeOp::executeUnary(), and EmulateSnippet::executeUnary().
|
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.
|
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
|
inline |
Check if operator is unary.
The operated can either be evaluated as unary or binary
|
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.
slot | is the input slot to recover |
sizeout | is the size of the output in bytes |
out | is the output value |
sizein | is the size of the inputs in bytes |
in | is the known input value |
Reimplemented in OpBehaviorIntSright, OpBehaviorIntRight, OpBehaviorIntLeft, OpBehaviorIntSub, and OpBehaviorIntAdd.
Referenced by TypeOp::recoverInputBinary(), OpBehaviorIntLeft::recoverInputBinary(), OpBehaviorIntRight::recoverInputBinary(), and OpBehaviorIntSright::recoverInputBinary().
|
virtual |
Reverse the unary op-code operation, recovering the input value.
If the output value is known, recover the input value.
sizeout | is the size of the output in bytes |
out | is the output value |
sizein | is the size of the input in bytes |
Reimplemented in OpBehaviorIntSext, OpBehaviorIntZext, and OpBehaviorCopy.
Referenced by TypeOp::recoverInputUnary().
|
static |
Build all pcode behaviors.
This routine generates a vector of OpBehavior objects indexed by opcode
inst | is the vector of behaviors to be filled |
trans | is the translator object needed by the floating point behaviors |
References CPUI_BOOL_AND, CPUI_BOOL_NEGATE, CPUI_BOOL_OR, CPUI_BOOL_XOR, CPUI_BRANCH, CPUI_BRANCHIND, CPUI_CALL, CPUI_CALLIND, CPUI_CALLOTHER, CPUI_CAST, CPUI_CBRANCH, CPUI_COPY, CPUI_CPOOLREF, CPUI_EXTRACT, CPUI_FLOAT_ABS, CPUI_FLOAT_ADD, CPUI_FLOAT_CEIL, CPUI_FLOAT_DIV, CPUI_FLOAT_EQUAL, CPUI_FLOAT_FLOAT2FLOAT, CPUI_FLOAT_FLOOR, CPUI_FLOAT_INT2FLOAT, CPUI_FLOAT_LESS, CPUI_FLOAT_LESSEQUAL, CPUI_FLOAT_MULT, CPUI_FLOAT_NAN, CPUI_FLOAT_NEG, CPUI_FLOAT_NOTEQUAL, CPUI_FLOAT_ROUND, CPUI_FLOAT_SQRT, CPUI_FLOAT_SUB, CPUI_FLOAT_TRUNC, CPUI_INDIRECT, CPUI_INSERT, CPUI_INT_2COMP, CPUI_INT_ADD, CPUI_INT_AND, CPUI_INT_CARRY, CPUI_INT_DIV, CPUI_INT_EQUAL, CPUI_INT_LEFT, CPUI_INT_LESS, CPUI_INT_LESSEQUAL, CPUI_INT_MULT, CPUI_INT_NEGATE, CPUI_INT_NOTEQUAL, CPUI_INT_OR, CPUI_INT_REM, CPUI_INT_RIGHT, CPUI_INT_SBORROW, CPUI_INT_SCARRY, CPUI_INT_SDIV, CPUI_INT_SEXT, CPUI_INT_SLESS, CPUI_INT_SLESSEQUAL, CPUI_INT_SREM, CPUI_INT_SRIGHT, CPUI_INT_SUB, CPUI_INT_XOR, CPUI_INT_ZEXT, CPUI_LOAD, CPUI_MAX, CPUI_MULTIEQUAL, CPUI_NEW, CPUI_PIECE, CPUI_POPCOUNT, CPUI_PTRADD, CPUI_PTRSUB, CPUI_RETURN, CPUI_SEGMENTOP, CPUI_STORE, CPUI_SUBPIECE, and OpBehavior().
Referenced by EmulatePcodeCache::EmulatePcodeCache().