Ghidra 11.3.2
Ghidra internal decompiler documentation.
|
Control the cloning of PcodeOps from within a basic block into another block. More...
#include <funcdata.hh>
Classes | |
struct | ClonePair |
Helper class for pairing a p-code op with its clone. More... | |
Public Member Functions | |
CloneBlockOps (Funcdata &fd) | |
Constructor. | |
void | cloneBlock (BlockBasic *b, BlockBasic *bprime, int4 inedge) |
Clone all p-code ops from a block into its copy. | |
Varnode * | cloneExpression (vector< PcodeOp * > &ops, PcodeOp *followOp) |
Clone p-code ops in an expression. | |
Private Member Functions | |
PcodeOp * | buildOpClone (PcodeOp *op) |
Produce a skeleton copy of the given PcodeOp. | |
void | buildVarnodeOutput (PcodeOp *origOp, PcodeOp *cloneOp) |
Clone the output Varnode of the given op onto its clone. | |
void | patchInputs (int4 inedge) |
Set the input Varnodes of all cloned ops. | |
Private Attributes | |
Funcdata & | data |
vector< ClonePair > | cloneList |
List of cloned ops. | |
map< PcodeOp *, PcodeOp * > | origToClone |
Map from original p-code op to its clone. | |
Control the cloning of PcodeOps from within a basic block into another block.
Used for splitting control-flow at a merge point. Can duplicate either a whole basic block, or an expression subset within a basic block.
Produce a skeleton copy of the given PcodeOp.
Make a basic clone of the p-code op copying its basic control-flow properties. In the case of a branch, the p-code op is not cloned and null is returned.
op | is the given PcodeOp |
References ghidra::PcodeOp::addlflags, ghidra::PcodeOp::badinstruction, ghidra::PcodeOp::calculated_bool, cloneList, ghidra::PcodeOp::code(), ghidra::CPUI_BRANCH, ghidra::PcodeOp::flags, ghidra::PcodeOp::getAddr(), ghidra::PcodeOp::halt, ghidra::PcodeOp::incidental_copy, ghidra::PcodeOp::indirect_creation, ghidra::PcodeOp::indirect_store, ghidra::PcodeOp::is_cpool_transformed, ghidra::PcodeOp::isBranch(), ghidra::PcodeOp::missing, ghidra::Funcdata::newOp(), ghidra::PcodeOp::no_indirect_collapse, ghidra::PcodeOp::nocollapse, ghidra::PcodeOp::nonprinting, ghidra::PcodeOp::noreturn, ghidra::PcodeOp::numInput(), ghidra::Funcdata::opSetOpcode(), origToClone, ghidra::PcodeOp::ptrflow, ghidra::PcodeOp::setAdditionalFlag(), ghidra::PcodeOp::setFlag(), ghidra::PcodeOp::special_print, ghidra::PcodeOp::special_prop, ghidra::PcodeOp::startbasic, ghidra::PcodeOp::startmark, ghidra::PcodeOp::stop_type_propagation, ghidra::PcodeOp::store_unmapped, and ghidra::PcodeOp::unimplemented.
Referenced by cloneBlock(), and cloneExpression().
Clone the output Varnode of the given op onto its clone.
Make a basic clone of the Varnode and its flags. The clone is created as an output of a previously cloned PcodeOp.
op | is the given op whose output should be cloned |
newop | is the cloned version |
References ghidra::Varnode::addlflags, ghidra::Varnode::addrforce, ghidra::Varnode::addrtied, ghidra::Varnode::externref, ghidra::Varnode::getAddr(), ghidra::Varnode::getFlags(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::Varnode::incidental_copy, ghidra::Varnode::indirect_creation, ghidra::Funcdata::newVarnodeOut(), ghidra::Varnode::nolocalalias, ghidra::Varnode::persist, ghidra::Varnode::precishi, ghidra::Varnode::precislo, ghidra::Varnode::ptrflow, ghidra::Varnode::readonly, ghidra::Varnode::return_address, ghidra::Varnode::setFlags(), ghidra::Varnode::spacebase, ghidra::Varnode::stack_store, ghidra::Varnode::volatil, and ghidra::Varnode::writemask.
Referenced by cloneBlock(), and cloneExpression().
void ghidra::CloneBlockOps::cloneBlock | ( | BlockBasic * | b, |
BlockBasic * | bprime, | ||
int4 | inedge | ||
) |
Clone all p-code ops from a block into its copy.
P-code in a basic block is cloned into the split version of the block.
b | is the original basic block |
bprime | is the cloned block |
inedge | is the incoming edge index that was split on |
References ghidra::BlockBasic::beginOp(), buildOpClone(), buildVarnodeOutput(), ghidra::BlockBasic::endOp(), ghidra::Funcdata::opInsertEnd(), and patchInputs().
Referenced by ghidra::Funcdata::nodeSplit().
Clone p-code ops in an expression.
P-code in the list is cloned right before the given followOp.
ops | is the list of ops to clone |
followOp | is the point where the cloned ops are inserted |
References buildOpClone(), buildVarnodeOutput(), cloneList, ghidra::PcodeOp::getOut(), ghidra::Funcdata::opInsertBefore(), and patchInputs().
Referenced by ghidra::RuleConditionalMove::constructBool().
|
private |
Set the input Varnodes of all cloned ops.
Map Varnodes that are inputs for PcodeOps in the original basic block to the input slots of the cloned ops. Constants and code ref Varnodes need to be duplicated, other Varnodes are shared between the ops. This routine also pulls an input Varnode out of original MULTIEQUAL ops and adds it back to the cloned MULTIEQUAL ops.
inedge | is the incoming edge index that was split on |
References cloneList, ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::CPUI_MULTIEQUAL, ghidra::Varnode::getAddr(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::isAnnotation(), ghidra::PcodeOp::isCall(), ghidra::Varnode::isConstant(), ghidra::Varnode::isFree(), ghidra::Varnode::isWritten(), ghidra::Funcdata::newCodeRef(), ghidra::PcodeOp::numInput(), ghidra::Funcdata::opRemoveInput(), ghidra::Funcdata::opSetInput(), ghidra::Funcdata::opSetOpcode(), origToClone, and ghidra::PcodeOp::setNumInputs().
Referenced by cloneBlock(), and cloneExpression().