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

Class for tracing changes of precision in floating point variables. More...

#include <subflow.hh>

Inheritance diagram for SubfloatFlow:
TransformManager

Public Member Functions

 SubfloatFlow (Funcdata *f, Varnode *root, int4 prec)
 
virtual bool preserveAddress (Varnode *vn, int4 bitSize, int4 lsbOffset) const
 Should the address of the given Varnode be preserved when constructing a piece. More...
 
bool doTrace (void)
 Trace logical value as far as possible. More...
 
- Public Member Functions inherited from TransformManager
 TransformManager (Funcdata *f)
 Constructor.
 
virtual ~TransformManager (void)
 Destructor.
 
FuncdatagetFunction (void) const
 Get function being transformed.
 
void clearVarnodeMarks (void)
 Clear mark for all Varnodes in the map.
 
TransformVarnewPreexistingVarnode (Varnode *vn)
 Make placeholder for preexisting Varnode. More...
 
TransformVarnewUnique (int4 size)
 Make placeholder for new unique space Varnode. More...
 
TransformVarnewConstant (int4 size, int4 lsbOffset, uintb val)
 Make placeholder for constant Varnode. More...
 
TransformVarnewIop (Varnode *vn)
 Make placeholder for special iop constant. More...
 
TransformVarnewPiece (Varnode *vn, int4 bitSize, int4 lsbOffset)
 Make placeholder for piece of a Varnode. More...
 
TransformVarnewSplit (Varnode *vn, const LaneDescription &description)
 Create placeholder nodes splitting a Varnode into its lanes. More...
 
TransformVarnewSplit (Varnode *vn, const LaneDescription &description, int4 numLanes, int4 startLane)
 Create placeholder nodes splitting a Varnode into a subset of lanes in the given description. More...
 
TransformOpnewOpReplace (int4 numParams, OpCode opc, PcodeOp *replace)
 Create a new placeholder op intended to replace an existing op. More...
 
TransformOpnewOp (int4 numParams, OpCode opc, TransformOp *follow)
 Create a new placeholder op that will not replace an existing op. More...
 
TransformOpnewPreexistingOp (int4 numParams, OpCode opc, PcodeOp *originalOp)
 Create a new placeholder op for an existing PcodeOp. More...
 
TransformVargetPreexistingVarnode (Varnode *vn)
 Get (or create) placeholder for preexisting Varnode. More...
 
TransformVargetPiece (Varnode *vn, int4 bitSize, int4 lsbOffset)
 Get (or create) placeholder piece. More...
 
TransformVargetSplit (Varnode *vn, const LaneDescription &description)
 Find (or create) placeholder nodes splitting a Varnode into its lanes. More...
 
TransformVargetSplit (Varnode *vn, const LaneDescription &description, int4 numLanes, int4 startLane)
 Find (or create) placeholder nodes splitting a Varnode into a subset of lanes from a description. More...
 
void opSetInput (TransformOp *rop, TransformVar *rvn, int4 slot)
 Mark given variable as input to given op. More...
 
void opSetOutput (TransformOp *rop, TransformVar *rvn)
 Mark given variable as output of given op. More...
 
void apply (void)
 Apply the full transform to the function.
 

Private Member Functions

TransformVarsetReplacement (Varnode *vn)
 Create and return a placeholder associated with the given Varnode. More...
 
bool traceForward (TransformVar *rvn)
 Try to trace logical variable through descendant Varnodes. More...
 
bool traceBackward (TransformVar *rvn)
 Trace a logical value backward through defining op one level. More...
 
bool processNextWork (void)
 Push the trace one hop from the placeholder at the top of the worklist. More...
 

Private Attributes

int4 precision
 Number of bytes of precision in the logical flow.
 
int4 terminatorCount
 Number of terminating nodes reachable via the root.
 
const FloatFormatformat
 The floating-point format of the logical value.
 
vector< TransformVar * > worklist
 Current list of placeholders that still need to be traced.
 

Additional Inherited Members

- Static Public Member Functions inherited from TransformManager
static bool preexistingGuard (int4 slot, TransformVar *rvn)
 Should newPreexistingOp be called. More...
 

Detailed Description

Class for tracing changes of precision in floating point variables.

It follows the flow of a logical lower precision value stored in higher precision locations and then rewrites the data-flow in terms of the lower precision, eliminating the precision conversions.

Constructor & Destructor Documentation

SubfloatFlow::SubfloatFlow ( Funcdata f,
Varnode root,
int4  prec 
)
Parameters
fis the function being transformed
rootis the start Varnode containing the logical value
precis the precision to assume for the logical value

References format, Funcdata::getArch(), Translate::getFloatFormat(), precision, setReplacement(), and Architecture::translate.

Member Function Documentation

bool SubfloatFlow::doTrace ( void  )

Trace logical value as far as possible.

The interpretation that the root Varnode contains a logical value with smaller precision is pushed through the data-flow. If the interpretation is inconsistent, false is returned. Otherwise a transform is constructed that makes the smaller precision the explicit size of Varnodes within the data-flow.

Returns
true if a transform consistent with the given precision can be built

References TransformManager::clearVarnodeMarks(), format, processNextWork(), terminatorCount, and worklist.

Referenced by RuleSubfloatConvert::applyOp().

bool SubfloatFlow::preserveAddress ( Varnode vn,
int4  bitSize,
int4  lsbOffset 
) const
virtual

Should the address of the given Varnode be preserved when constructing a piece.

A new Varnode will be created that represents a logical piece of the given Varnode. This routine determines whether the new Varnode should be constructed using storage which overlaps the given Varnode. It returns true if overlapping storage should be used, false if the new Varnode should be constructed as a unique temporary.

Parameters
vnis the given Varnode
bitSizeis the logical size of the Varnode piece being constructed
lsbOffsetis the least significant bit position of the logical value within the given Varnode
Returns
true if overlapping storage should be used in construction

Reimplemented from TransformManager.

References Varnode::isInput().

bool SubfloatFlow::processNextWork ( void  )
private

Push the trace one hop from the placeholder at the top of the worklist.

The logical value for the value on top of the worklist stack is pushed back to the input Varnodes of the operation defining it. Then the value is pushed forward through all operations that read it.

Returns
true if the trace is successfully pushed

References SplitFlow::traceBackward(), SplitFlow::traceForward(), and SplitFlow::worklist.

Referenced by doTrace().

TransformVar * SubfloatFlow::setReplacement ( Varnode vn)
private
bool SubfloatFlow::traceBackward ( TransformVar rvn)
private

Trace a logical value backward through defining op one level.

Given an existing variable placeholder look at the op defining it and define placeholder variables for all its inputs. Put the new placeholders onto the worklist if appropriate.

Parameters
rvnis the given variable placeholder
Returns
true if the logical value can be traced properly

References PcodeOp::code(), CPUI_COPY, CPUI_FLOAT_ABS, CPUI_FLOAT_ADD, CPUI_FLOAT_CEIL, CPUI_FLOAT_DIV, CPUI_FLOAT_FLOAT2FLOAT, CPUI_FLOAT_FLOOR, CPUI_FLOAT_INT2FLOAT, CPUI_FLOAT_MULT, CPUI_FLOAT_NEG, CPUI_FLOAT_ROUND, CPUI_FLOAT_SQRT, CPUI_FLOAT_SUB, CPUI_MULTIEQUAL, TransformVar::getDef(), Varnode::getDef(), TransformOp::getIn(), PcodeOp::getIn(), Varnode::getOffset(), TransformVar::getOriginal(), TransformManager::getPreexistingVarnode(), Varnode::getSize(), Varnode::isConstant(), Varnode::isFree(), TransformManager::newConstant(), TransformManager::newOpReplace(), PcodeOp::numInput(), TransformManager::opSetInput(), TransformManager::opSetOutput(), and SplitFlow::setReplacement().

Referenced by LaneDivide::processNextWork().

bool SubfloatFlow::traceForward ( TransformVar rvn)
private

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