Ghidra 11.3.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::CloneBlockOps Class Reference

Control the cloning of PcodeOps from within a basic block into another block. More...

#include <funcdata.hh>

Collaboration diagram for ghidra::CloneBlockOps:
[legend]

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.
 
VarnodecloneExpression (vector< PcodeOp * > &ops, PcodeOp *followOp)
 Clone p-code ops in an expression.
 

Private Member Functions

PcodeOpbuildOpClone (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

Funcdatadata
 
vector< ClonePaircloneList
 List of cloned ops.
 
map< PcodeOp *, PcodeOp * > origToClone
 Map from original p-code op to its clone.
 

Detailed Description

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.

Member Function Documentation

◆ buildOpClone()

◆ buildVarnodeOutput()

◆ cloneBlock()

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.

Parameters
bis the original basic block
bprimeis the cloned block
inedgeis 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().

◆ cloneExpression()

Varnode * ghidra::CloneBlockOps::cloneExpression ( vector< PcodeOp * > &  ops,
PcodeOp followOp 
)

Clone p-code ops in an expression.

P-code in the list is cloned right before the given followOp.

Parameters
opsis the list of ops to clone
followOpis the point where the cloned ops are inserted
Returns
the output Varnode of the last cloned op

References buildOpClone(), buildVarnodeOutput(), cloneList, ghidra::PcodeOp::getOut(), ghidra::Funcdata::opInsertBefore(), and patchInputs().

Referenced by ghidra::RuleConditionalMove::constructBool().

◆ patchInputs()

void ghidra::CloneBlockOps::patchInputs ( int4  inedge)
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.

Parameters
inedgeis 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().


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