decompiler
1.0.0
|
Casting strategies that are specific to the C language. More...
#include <cast.hh>
Public Member Functions | |
virtual int4 | localExtensionType (const Varnode *vn) const |
Decide on integer promotion by examining just local properties of the given Varnode. More... | |
virtual int4 | intPromotionType (const Varnode *vn) const |
Calculate the integer promotion code of a given Varnode. More... | |
virtual bool | checkIntPromotionForCompare (const PcodeOp *op, int4 slot) const |
Check if integer promotion forces a cast for the given comparison op and slot. More... | |
virtual bool | checkIntPromotionForExtension (const PcodeOp *op) const |
Check if integer promotion forces a cast for the input to the given extension. More... | |
virtual bool | isExtensionCastImplied (const PcodeOp *op, const PcodeOp *readOp) const |
Is the given ZEXT/SEXT cast implied by the expression its in? More... | |
virtual Datatype * | castStandard (Datatype *reqtype, Datatype *curtype, bool care_uint_int, bool care_ptr_uint) const |
Does there need to be a visible cast between the given data-types. More... | |
virtual Datatype * | arithmeticOutputStandard (const PcodeOp *op) |
What is the output data-type produced by the given integer arithmetic operation. More... | |
virtual bool | isSubpieceCast (Datatype *outtype, Datatype *intype, uint4 offset) const |
Is truncating an input data-type, producing an output data-type, considered a cast. More... | |
virtual bool | isSubpieceCastEndian (Datatype *outtype, Datatype *intype, uint4 offset, bool isbigend) const |
Is the given data-type truncation considered a cast, given endianess concerns. More... | |
virtual bool | isSextCast (Datatype *outtype, Datatype *intype) const |
Is sign-extending an input data-type, producing an output data-type, considered a cast. More... | |
virtual bool | isZextCast (Datatype *outtype, Datatype *intype) const |
Is zero-extending an input data-type, producing an output data-type, considered a cast. More... | |
Public Member Functions inherited from CastStrategy | |
CastStrategy (void) | |
Constructor. | |
void | setTypeFactory (TypeFactory *t) |
Establish the data-type factory. More... | |
virtual | ~CastStrategy (void) |
Destructor. | |
Additional Inherited Members | |
Public Types inherited from CastStrategy | |
enum | IntPromotionCode { NO_PROMOTION = -1, UNKNOWN_PROMOTION = 0, UNSIGNED_EXTENSION = 1, SIGNED_EXTENSION = 2, EITHER_EXTENSION = 3 } |
Types of integer promotion. More... | |
Protected Attributes inherited from CastStrategy | |
TypeFactory * | tlst |
Type factory associated with the Architecture. | |
int4 | promoteSize |
Size of int data-type, (size that integers get promoted to) | |
Casting strategies that are specific to the C language.
What is the output data-type produced by the given integer arithmetic operation.
op | is the given operation |
Implements CastStrategy.
References TypeFactory::getBase(), Varnode::getHigh(), PcodeOp::getIn(), Datatype::getMetatype(), Datatype::getSize(), HighVariable::getType(), PcodeOp::numInput(), CastStrategy::tlst, TYPE_BOOL, TYPE_INT, and Datatype::typeOrder().
|
virtual |
Does there need to be a visible cast between the given data-types.
The cast is from a current data-type to an expected data-type. NULL is returned if no cast is required, otherwise the data-type to cast to (usually the expected data-type) is returned.
reqtype | is the expected data-type |
curtype | is the current data-type |
care_uint_int | is true if we care about a change in signedness |
care_ptr_uint | is true if we care about conversions between pointers and unsigned values |
Implements CastStrategy.
Reimplemented in CastStrategyJava.
References Datatype::getMetatype(), Datatype::getSize(), Datatype::hasSameVariableBase(), Datatype::isVariableLength(), TYPE_BOOL, TYPE_CODE, TYPE_INT, TYPE_PTR, TYPE_UINT, TYPE_UNKNOWN, and TYPE_VOID.
|
virtual |
Check if integer promotion forces a cast for the given comparison op and slot.
Compute to what level the given slot has seen integer promotion and if a cast is required before the comparison operator makes sense.
op | is the given comparison operator |
slot | is the input slot being tested |
Implements CastStrategy.
References PcodeOp::getIn(), CastStrategy::intPromotionType(), CastStrategy::NO_PROMOTION, and CastStrategy::UNKNOWN_PROMOTION.
|
virtual |
Check if integer promotion forces a cast for the input to the given extension.
Compute to what level the given slot has seen integer promotion and if a cast is required before the extension operator makes sense.
op | is the given extension operator INT_ZEXT or INT_SEXT |
Implements CastStrategy.
References PcodeOp::code(), CPUI_INT_SEXT, CPUI_INT_ZEXT, PcodeOp::getIn(), CastStrategy::intPromotionType(), CastStrategy::NO_PROMOTION, CastStrategy::SIGNED_EXTENSION, CastStrategy::UNKNOWN_PROMOTION, and CastStrategy::UNSIGNED_EXTENSION.
|
virtual |
Calculate the integer promotion code of a given Varnode.
Recursively examine the expression defining the Varnode as necessary
vn | is the given Varnode |
Implements CastStrategy.
References PcodeOp::code(), CPUI_INT_2COMP, CPUI_INT_ADD, CPUI_INT_AND, CPUI_INT_DIV, CPUI_INT_LEFT, CPUI_INT_MULT, CPUI_INT_NEGATE, CPUI_INT_OR, CPUI_INT_REM, CPUI_INT_RIGHT, CPUI_INT_SDIV, CPUI_INT_SREM, CPUI_INT_SRIGHT, CPUI_INT_SUB, CPUI_INT_XOR, Varnode::getDef(), PcodeOp::getIn(), Varnode::getSize(), Varnode::isConstant(), Varnode::isExplicit(), Varnode::isWritten(), CastStrategy::localExtensionType(), CastStrategy::NO_PROMOTION, CastStrategy::promoteSize, CastStrategy::SIGNED_EXTENSION, CastStrategy::UNKNOWN_PROMOTION, and CastStrategy::UNSIGNED_EXTENSION.
|
virtual |
Is the given ZEXT/SEXT cast implied by the expression its in?
We've already determined that the given ZEXT or SEXT op can be viewed as a natural cast operation. Determine if the cast is implied by the expression its and doesn't need to be printed.
op | is the given ZEXT or SEXT PcodeOp |
readOp | is the PcodeOp consuming the output of the extensions (or null) |
Implements CastStrategy.
References PcodeOp::code(), CPUI_INT_ADD, CPUI_INT_AND, CPUI_INT_DIV, CPUI_INT_EQUAL, CPUI_INT_LESS, CPUI_INT_LESSEQUAL, CPUI_INT_MULT, CPUI_INT_NOTEQUAL, CPUI_INT_OR, CPUI_INT_SLESS, CPUI_INT_SLESSEQUAL, CPUI_INT_SUB, CPUI_INT_XOR, CPUI_PTRADD, Varnode::getHigh(), PcodeOp::getIn(), Datatype::getMetatype(), PcodeOp::getOut(), Varnode::getSize(), PcodeOp::getSlot(), HighVariable::getType(), Varnode::isConstant(), Varnode::isExplicit(), and CastStrategy::promoteSize.
Is sign-extending an input data-type, producing an output data-type, considered a cast.
Data-types must be provided from the input and output of an INT_SEXT operation.
outtype | is the output data-type |
intype | is the input data-type |
Implements CastStrategy.
References Datatype::getMetatype(), TYPE_BOOL, TYPE_INT, and TYPE_UINT.
|
virtual |
Is truncating an input data-type, producing an output data-type, considered a cast.
Data-types must be provided from the input and output of a SUBPIECE operation.
outtype | is the output data-type |
intype | is the input data-type |
offset | is number of bytes truncated by the SUBPIECE |
Implements CastStrategy.
References Datatype::getMetatype(), Datatype::getSize(), TYPE_FLOAT, TYPE_INT, TYPE_PTR, TYPE_UINT, and TYPE_UNKNOWN.
|
virtual |
Is the given data-type truncation considered a cast, given endianess concerns.
This is equivalent to isSubpieceCast() but where the truncation is accomplished by pulling bytes directly out of memory. We assume the input data-type is layed down in memory, and we pull the output value starting at a given byte offset.
outtype | is the output data-type |
intype | is the input data-type |
offset | is the given byte offset (into the input memory) |
isbigend | is true if the address space holding the memory is big endian. |
Implements CastStrategy.
References Datatype::getSize(), and CastStrategy::isSubpieceCast().
Is zero-extending an input data-type, producing an output data-type, considered a cast.
Data-types must be provided from the input and output of an INT_ZEXT operation.
outtype | is the output data-type |
intype | is the input data-type |
Implements CastStrategy.
Reimplemented in CastStrategyJava.
References Datatype::getMetatype(), TYPE_BOOL, TYPE_INT, and TYPE_UINT.
|
virtual |
Decide on integer promotion by examining just local properties of the given Varnode.
vn | is the given Varnode |
Implements CastStrategy.
References PcodeOp::code(), CPUI_CAST, CPUI_INT_AND, CPUI_LOAD, CastStrategy::EITHER_EXTENSION, Varnode::getDef(), Varnode::getHigh(), PcodeOp::getIn(), Datatype::getMetatype(), Varnode::getOffset(), Varnode::getSize(), HighVariable::getType(), PcodeOp::isBoolOutput(), PcodeOp::isCall(), Varnode::isConstant(), Varnode::isExplicit(), Varnode::isWritten(), signbit_negative(), CastStrategy::SIGNED_EXTENSION, TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_UNKNOWN, CastStrategy::UNKNOWN_PROMOTION, and CastStrategy::UNSIGNED_EXTENSION.