decompiler
1.0.0
|
Utilities for processing data structures associated with a single function. More...
#include "architecture.hh"
#include "override.hh"
#include "heritage.hh"
#include "merge.hh"
#include "dynamic.hh"
#include "unionresolve.hh"
Classes | |
class | ghidra::Funcdata |
Container for data structures associated with a single function. More... | |
class | ghidra::PcodeEmitFd |
A p-code emitter for building PcodeOp objects. More... | |
class | ghidra::AncestorRealistic |
Helper class for determining if Varnodes can trace their value from a legitimate source. More... | |
class | ghidra::AncestorRealistic::State |
Node in a depth first traversal of ancestors. More... | |
Functions | |
int4 | ghidra::opFlipInPlaceTest (PcodeOp *op, vector< PcodeOp * > &fliplist) |
Trace a boolean value to a set of PcodeOps that can be changed to flip the boolean value. More... | |
void | ghidra::opFlipInPlaceExecute (Funcdata &data, vector< PcodeOp * > &fliplist) |
Perform op-code flips (in-place) to change a boolean value. More... | |
PcodeOp * | ghidra::earliestUseInBlock (Varnode *vn, BlockBasic *bl) |
Get the earliest use/read of a Varnode in a specified basic block. More... | |
PcodeOp * | ghidra::cseFindInBlock (PcodeOp *op, Varnode *vn, BlockBasic *bl, PcodeOp *earliest) |
Find a duplicate calculation of a given PcodeOp reading a specific Varnode. More... | |
PcodeOp * | ghidra::cseElimination (Funcdata &data, PcodeOp *op1, PcodeOp *op2) |
Perform a Common Subexpression Elimination step. More... | |
void | ghidra::cseEliminateList (Funcdata &data, vector< pair< uintm, PcodeOp * > > &list, vector< Varnode * > &outlist) |
Perform Common Subexpression Elimination on a list of Varnode descendants. More... | |
Utilities for processing data structures associated with a single function.
void ghidra::cseEliminateList | ( | Funcdata & | data, |
vector< pair< uintm, PcodeOp * > > & | list, | ||
vector< Varnode * > & | outlist | ||
) |
Perform Common Subexpression Elimination on a list of Varnode descendants.
The list consists of PcodeOp descendants of a single Varnode paired with a hash value. The hash serves as a primary test for duplicate calculations; if it doesn't match the PcodeOps aren't common subexpressions. This method searches for hash matches then does secondary testing and eliminates any redundancy it finds.
data | is the function being modified |
list | is the list of (hash, PcodeOp) pairs |
outlist | will hold Varnodes produced by duplicate calculations |
References ghidra::cseEliminateList(), ghidra::cseElimination(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::isCseMatch(), ghidra::PcodeOp::isDead(), and ghidra::Funcdata::isHeritaged().
Referenced by ghidra::RuleSelectCse::applyOp(), ghidra::cseEliminateList(), and ghidra::AncestorRealistic::mark().
Perform a Common Subexpression Elimination step.
Assuming the two given PcodeOps perform the identical operation on identical operands (depth 1 functional equivalence) eliminate the redundancy. Return the remaining (dominating) PcodeOp. If neither op dominates the other, both are eliminated, and a new PcodeOp is built at a commonly accessible point.
data | is the function being modified |
op1 | is the first of the given PcodeOps |
op2 | is the second given PcodeOp |
References ghidra::PcodeOp::code(), ghidra::cseElimination(), ghidra::FlowBlock::findCommonBlock(), ghidra::Varnode::getAddr(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::SeqNum::getOrder(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::getParent(), ghidra::PcodeOp::getSeqNum(), ghidra::Varnode::getSize(), ghidra::BlockBasic::getStop(), ghidra::Varnode::isConstant(), ghidra::Funcdata::newConstant(), ghidra::Funcdata::newOp(), ghidra::Funcdata::newVarnodeOut(), ghidra::PcodeOp::numInput(), ghidra::Funcdata::opDestroy(), ghidra::Funcdata::opInsertEnd(), ghidra::Funcdata::opSetInput(), ghidra::Funcdata::opSetOpcode(), and ghidra::Funcdata::totalReplace().
Referenced by ghidra::cseEliminateList(), ghidra::cseElimination(), and ghidra::AncestorRealistic::mark().
PcodeOp * ghidra::cseFindInBlock | ( | PcodeOp * | op, |
Varnode * | vn, | ||
BlockBasic * | bl, | ||
PcodeOp * | earliest | ||
) |
Find a duplicate calculation of a given PcodeOp reading a specific Varnode.
We only match 1 level of calculation. Additionally the duplicate must occur in the indicated basic block, earlier than a specified op.
op | is the given PcodeOp |
vn | is the specific Varnode that must be involved in the calculation |
bl | is the indicated basic block |
earliest | is the specified op to be earlier than |
References ghidra::Varnode::beginDescend(), ghidra::cseFindInBlock(), ghidra::Varnode::endDescend(), ghidra::SeqNum::getOrder(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::getParent(), and ghidra::PcodeOp::getSeqNum().
Referenced by ghidra::RuleMultiCollapse::applyOp(), ghidra::cseFindInBlock(), ghidra::RulePushMulti::findSubstitute(), and ghidra::AncestorRealistic::mark().
PcodeOp * ghidra::earliestUseInBlock | ( | Varnode * | vn, |
BlockBasic * | bl | ||
) |
Get the earliest use/read of a Varnode in a specified basic block.
vn | is the Varnode to search for |
bl | is the specified basic block in which to search |
References ghidra::Varnode::beginDescend(), ghidra::earliestUseInBlock(), ghidra::Varnode::endDescend(), ghidra::SeqNum::getOrder(), ghidra::PcodeOp::getParent(), and ghidra::PcodeOp::getSeqNum().
Referenced by ghidra::RulePushMulti::applyOp(), ghidra::RuleMultiCollapse::applyOp(), ghidra::earliestUseInBlock(), and ghidra::AncestorRealistic::mark().
Perform op-code flips (in-place) to change a boolean value.
The precomputed list of PcodeOps have their op-codes modified to facilitate the flip.
data | is the function being modified |
fliplist | is the list of PcodeOps to modify |
References ghidra::PcodeOp::code(), ghidra::CPUI_BOOL_AND, ghidra::CPUI_BOOL_OR, ghidra::CPUI_COPY, ghidra::CPUI_INT_LESSEQUAL, ghidra::CPUI_INT_SLESSEQUAL, ghidra::CPUI_MAX, ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::getSlot(), ghidra::Varnode::loneDescend(), ghidra::Funcdata::opDestroy(), ghidra::opFlipInPlaceExecute(), ghidra::Funcdata::opSetInput(), ghidra::Funcdata::opSetOpcode(), ghidra::Funcdata::opSwapInput(), and ghidra::Funcdata::replaceLessequal().
Referenced by ghidra::ActionNormalizeBranches::apply(), ghidra::AncestorRealistic::mark(), ghidra::opFlipInPlaceExecute(), and ghidra::BlockIf::preferComplement().
Trace a boolean value to a set of PcodeOps that can be changed to flip the boolean value.
The boolean Varnode is either the output of the given PcodeOp or the first input if the PcodeOp is a CBRANCH. The list of ops that need flipping is returned in an array
op | is the given PcodeOp |
fliplist | is the array that will hold the ops to flip |
References ghidra::PcodeOp::code(), ghidra::CPUI_BOOL_AND, ghidra::CPUI_BOOL_NEGATE, ghidra::CPUI_BOOL_OR, ghidra::CPUI_CBRANCH, ghidra::CPUI_FLOAT_EQUAL, ghidra::CPUI_FLOAT_NOTEQUAL, ghidra::CPUI_INT_EQUAL, ghidra::CPUI_INT_LESS, ghidra::CPUI_INT_LESSEQUAL, ghidra::CPUI_INT_NOTEQUAL, ghidra::CPUI_INT_SLESS, ghidra::CPUI_INT_SLESSEQUAL, ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::isConstant(), ghidra::Varnode::isWritten(), ghidra::Varnode::loneDescend(), and ghidra::opFlipInPlaceTest().
Referenced by ghidra::ActionNormalizeBranches::apply(), ghidra::BlockBasic::flipInPlaceTest(), ghidra::AncestorRealistic::mark(), and ghidra::opFlipInPlaceTest().