decompiler 1.0.0
Public Member Functions | Static Public Member Functions | List of all members
TypeOpSubpiece Class Reference

Information about the SUBPIECE op-code. More...

#include <typeop.hh>

Inheritance diagram for TypeOpSubpiece:
TypeOpFunc TypeOp

Public Member Functions

 TypeOpSubpiece (TypeFactory *t)
 Constructor.
 
virtual DatatypegetOutputToken (const PcodeOp *op, CastStrategy *castStrategy) const
 Find the data-type of the output that would be assigned by a compiler. More...
 
virtual DatatypepropagateType (Datatype *alttype, PcodeOp *op, Varnode *invn, Varnode *outvn, int4 inslot, int4 outslot)
 Propagate an incoming data-type across a specific PcodeOp. More...
 
virtual string getOperatorName (const PcodeOp *op) const
 Get the name of the op-code as it should be displayed in context. More...
 
virtual void push (PrintLanguage *lng, const PcodeOp *op, const PcodeOp *readOp) const
 Push the specific PcodeOp to the emitter's RPN stack. More...
 
- Public Member Functions inherited from TypeOpFunc
 TypeOpFunc (TypeFactory *t, OpCode opc, const string &n, type_metatype mout, type_metatype min)
 Constructor.
 
virtual DatatypegetOutputLocal (const PcodeOp *op) const
 Find the minimal (or suggested) data-type of an output to this op-code. More...
 
virtual DatatypegetInputLocal (const PcodeOp *op, int4 slot) const
 Find the minimal (or suggested) data-type of an input to this op-code. More...
 
virtual void printRaw (ostream &s, const PcodeOp *op)
 Print (for debugging purposes) this specific PcodeOp to the stream. More...
 
- Public Member Functions inherited from TypeOp
 TypeOp (TypeFactory *t, OpCode opc, const string &n)
 Constructor. More...
 
virtual ~TypeOp (void)
 Destructor.
 
const string & getName (void) const
 Get the display name of the op-code.
 
OpCode getOpcode (void) const
 Get the op-code value.
 
uint4 getFlags (void) const
 Get the properties associated with the op-code.
 
OpBehaviorgetBehavior (void) const
 Get the behavior associated with the op-code.
 
uintb evaluateUnary (int4 sizeout, int4 sizein, uintb in1) const
 Emulate the unary op-code on an input value. More...
 
uintb evaluateBinary (int4 sizeout, int4 sizein, uintb in1, uintb in2) const
 Emulate the binary op-code on an input value. More...
 
uintb recoverInputBinary (int4 slot, int4 sizeout, uintb out, int4 sizein, uintb in) const
 Reverse the binary op-code operation, recovering a constant input value. More...
 
uintb recoverInputUnary (int4 sizeout, uintb out, int4 sizein) const
 Reverse the unary op-code operation, recovering a constant input value. More...
 
bool isCommutative (void) const
 Return true if this op-code is commutative. More...
 
bool inheritsSign (void) const
 Return true if the op-code inherits its signedness from its inputs.
 
bool inheritsSignFirstParamOnly (void) const
 Return true if the op-code inherits its signedness from only its first input.
 
bool isShiftOp (void) const
 Return true if the op-code is a shift (INT_LEFT, INT_RIGHT, or INT_SRIGHT)
 
virtual DatatypegetOutputLocal (const PcodeOp *op) const
 Find the minimal (or suggested) data-type of an output to this op-code. More...
 
virtual DatatypegetInputLocal (const PcodeOp *op, int4 slot) const
 Find the minimal (or suggested) data-type of an input to this op-code. More...
 
virtual DatatypegetOutputToken (const PcodeOp *op, CastStrategy *castStrategy) const
 Find the data-type of the output that would be assigned by a compiler. More...
 
virtual DatatypegetInputCast (const PcodeOp *op, int4 slot, const CastStrategy *castStrategy) const
 Find the data-type of the input to a specific PcodeOp. More...
 
virtual DatatypepropagateType (Datatype *alttype, PcodeOp *op, Varnode *invn, Varnode *outvn, int4 inslot, int4 outslot)
 Propagate an incoming data-type across a specific PcodeOp. More...
 
virtual void push (PrintLanguage *lng, const PcodeOp *op, const PcodeOp *readOp) const =0
 Push the specific PcodeOp to the emitter's RPN stack. More...
 
virtual void printRaw (ostream &s, const PcodeOp *op)=0
 Print (for debugging purposes) this specific PcodeOp to the stream. More...
 
virtual string getOperatorName (const PcodeOp *op) const
 Get the name of the op-code as it should be displayed in context. More...
 

Static Public Member Functions

static const TypeFieldtestExtraction (bool useHigh, const PcodeOp *op, Datatype *&parent, int4 &offset)
 Test if the given SUBPIECE PcodeOp is acting as a field extraction operator. More...
 
static int4 computeByteOffsetForComposite (const PcodeOp *op)
 Compute the byte offset into an assumed composite data-type produced by the given CPUI_SUBPIECE. More...
 
- Static Public Member Functions inherited from TypeOp
static void registerInstructions (vector< TypeOp * > &inst, TypeFactory *tlst, const Translate *trans)
 Build a map from op-code value to the TypeOp information objects. More...
 
static void selectJavaOperators (vector< TypeOp * > &inst, bool val)
 Toggle Java specific aspects of the op-code information. More...
 

Additional Inherited Members

- Public Types inherited from TypeOp
enum  { inherits_sign = 1 , inherits_sign_zero = 2 , shift_op = 4 }
 
- Protected Member Functions inherited from TypeOp
virtual void setMetatypeIn (type_metatype val)
 Set the data-type associated with inputs to this opcode. More...
 
virtual void setMetatypeOut (type_metatype val)
 Set the data-type associated with outputs of this opcode. More...
 
virtual void setSymbol (const string &nm)
 Set the display symbol associated with the op-code.
 
- Protected Attributes inherited from TypeOp
TypeFactorytlst
 Pointer to data-type factory.
 
OpCode opcode
 The op-code value.
 
uint4 opflags
 Cached pcode-op properties for this op-code.
 
uint4 addlflags
 Additional properties.
 
string name
 Symbol denoting this operation.
 
OpBehaviorbehave
 Object for emulating the behavior of the op-code.
 

Detailed Description

Information about the SUBPIECE op-code.

Member Function Documentation

◆ computeByteOffsetForComposite()

int4 TypeOpSubpiece::computeByteOffsetForComposite ( const PcodeOp op)
static

Compute the byte offset into an assumed composite data-type produced by the given CPUI_SUBPIECE.

If the input Varnode is a composite data-type, the extracted result of the SUBPIECE represent a range of bytes starting at a particular offset within the data-type. Return this offset, which depends on endianness of the input.

Parameters
opis the given CPUI_SUBPIECE
Returns
the byte offset into the composite represented by the output of the SUBPIECE

References PcodeOp::getIn(), Varnode::getOffset(), PcodeOp::getOut(), Varnode::getSize(), Varnode::getSpace(), and AddrSpace::isBigEndian().

Referenced by propagateType(), ScoreUnionFields::scoreTrialDown(), and testExtraction().

◆ getOperatorName()

string TypeOpSubpiece::getOperatorName ( const PcodeOp op) const
virtual

Get the name of the op-code as it should be displayed in context.

Depending on the context, the same op-code may get displayed in different ways.

Parameters
opis the PcodeOp context
Returns
the display token

Reimplemented from TypeOp.

References PcodeOp::getIn(), PcodeOp::getOut(), Varnode::getSize(), and TypeOp::name.

◆ getOutputToken()

Datatype * TypeOpSubpiece::getOutputToken ( const PcodeOp op,
CastStrategy castStrategy 
) const
virtual

Find the data-type of the output that would be assigned by a compiler.

Calculate the actual data-type of the output for a specific PcodeOp as would be assigned by a C compiler parsing a grammar containing this op.

Parameters
opis the specific PcodeOp
castStrategyis the current casting strategy
Returns
the data-type

Reimplemented from TypeOp.

References TypeFactory::getBase(), Varnode::getHighTypeDefFacing(), Datatype::getMetatype(), PcodeOp::getOut(), Datatype::getSize(), Varnode::getSize(), testExtraction(), TypeOp::tlst, TypeField::type, TYPE_INT, and TYPE_UNKNOWN.

◆ propagateType()

Datatype * TypeOpSubpiece::propagateType ( Datatype alttype,
PcodeOp op,
Varnode invn,
Varnode outvn,
int4  inslot,
int4  outslot 
)
virtual

Propagate an incoming data-type across a specific PcodeOp.

The data-type can propagate between any two Varnodes attached to the PcodeOp, either in or out. The pair invn and inslot indicate the Varnode holding the incoming data-type. The pair outvn and outslot indicate the Varnode that will hold the outgoing data-type. The data-type for the outgoing Varnode is returned, which may be different then the incoming data-type as the PcodeOp can transform the data-type as it propagates.

Parameters
alttypeis the incoming data-type
opis the PcodeOp to propagate across
invnis the Varnode holding the incoming data-type
outvnis the Varnode that will hold the outgoing data-type
inslotindicates how the incoming Varnode is attached to the PcodeOp (-1 indicates output >= indicates input)
outslotindicates how the outgoing Varnode is attached to the PcodeOp
Returns
the outgoing data-type or null (to indicate no propagation)

Reimplemented from TypeOp.

References computeByteOffsetForComposite(), Datatype::findTruncation(), Datatype::getMetatype(), Datatype::getSize(), Varnode::getSize(), Datatype::resolveTruncation(), TypeField::type, TYPE_PARTIALUNION, TYPE_STRUCT, and TYPE_UNION.

◆ push()

virtual void TypeOpSubpiece::push ( PrintLanguage lng,
const PcodeOp op,
const PcodeOp readOp 
) const
inlinevirtual

Push the specific PcodeOp to the emitter's RPN stack.

Given a specific language and PcodeOp, emit the expression rooted at the operation.

Parameters
lngis the PrintLanguage to emit
opis the specific PcodeOp
readOpis the PcodeOp consuming the output (or null)

Implements TypeOp.

References PrintLanguage::opSubpiece().

◆ testExtraction()

const TypeField * TypeOpSubpiece::testExtraction ( bool  useHigh,
const PcodeOp op,
Datatype *&  parent,
int4 &  offset 
)
static

Test if the given SUBPIECE PcodeOp is acting as a field extraction operator.

For packed structures with small fields, SUBPIECE may be used to extract the field. Test if the HighVariable being truncated is a structure and if the truncation produces part of a single field. If so return the TypeField descriptor, and pass back the parent structure and the number of least significant bytes that have been truncated from the field.

Parameters
useHighis true if the HighVariable data-type is checked, otherwise the Varnode data-type is used
opis the given SUBPIECE PcodeOp
parentholds the parent Datatype being passed back
offsetholds the LSB offset being passed back
Returns
the TypeField if a field is being extracted or null otherwise

References computeByteOffsetForComposite(), Datatype::findTruncation(), Varnode::getHighTypeReadFacing(), PcodeOp::getIn(), Datatype::getMetatype(), PcodeOp::getOut(), Varnode::getSize(), Varnode::getTypeReadFacing(), TYPE_PARTIALUNION, TYPE_STRUCT, and TYPE_UNION.

Referenced by RuleSubRight::applyOp(), getOutputToken(), and PrintC::opSubpiece().


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