Package ghidra.pcode.emu.jit.analysis

# Class JitControlFlowModel.BlockSplitter

java.lang.Object
ghidra.pcode.emu.jit.analysis.JitControlFlowModel.BlockSplitter

Enclosing class:
  `JitControlFlowModel`

public abstract static class JitControlFlowModel.BlockSplitter extends Object
A class that splits a sequence of ops and associated branches into basic blocks.

This is the kernel of control flow analysis. It first indexes the branches by source and target op. Note that only non-fall-through branches are known at this point. Then, it traverses the list of ops. A split occurs following an op that is a branch source and/or preceding an op that is a branch target. A block is constructed when such a split point is encountered. In the case of a branch source, the branch is added to the newly constructed block. As traversal proceeds to the next op, it checks if the immediately-preceding block should have fall through (conditional or unconditional) by examining its last op. It adds a new fall-through branch if so. The end of the p-code op list is presumed a split point. If that final block "should have" fall through, an `JitControlFlowModel.UnterminatedFlowException` is thrown.

Once all the splitting is done, we have the blocks and all the branches (internal or external) that leave each block. We then compute all the branches (internal) that enter each block and the associated flows in both directions.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BlockSplitter(PcodeProgram program)`
  Construct a new block splitter to process the given program

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addBranches(Collection<? extends JitPassage.Branch> branches)`
  Notify the splitter of the given branches before analysis
  `protected abstract JitPassage.IntBranch`
  `newFallthroughIntBranch(PcodeOp from, PcodeOp to)`
  `SequencedMap<PcodeOp,JitControlFlowModel.JitBlock>`
  `splitBlocks()`
  Perform the actual analysis

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### BlockSplitter

    public BlockSplitter(PcodeProgram program)
    Construct a new block splitter to process the given program

    No analysis is performed in the constructor. The client must call `addBranches(Collection)` and then `splitBlocks()`.

    Parameters:
      `program` - the program, i.e., list of p-code ops

- ## Method Details

  - ### newFallthroughIntBranch

    protected abstract JitPassage.IntBranch newFallthroughIntBranch(PcodeOp from, PcodeOp to)

  - ### addBranches

    public void addBranches(Collection<? extends JitPassage.Branch> branches)
    Notify the splitter of the given branches before analysis

    The splitter immediately indexes the given branches by source and target op.

    Parameters:
      `branches` - the branches

  - ### splitBlocks

    public SequencedMap<PcodeOp,JitControlFlowModel.JitBlock> splitBlocks()
    Perform the actual analysis
    Returns:
      the resulting split blocks, keyed by `JitControlFlowModel.JitBlock.start()`