decompiler
1.0.0
|
Description of a control-flow block containing PcodeOps. More...
#include <block.hh>
Public Types | |
enum | block_type { t_plain, t_basic, t_graph, t_copy, t_goto, t_multigoto, t_ls, t_condition, t_if, t_whiledo, t_dowhile, t_switch, t_infloop, t_for } |
The possible block types. | |
enum | block_flags { f_goto_goto = 1, f_break_goto = 2, f_continue_goto = 4, f_switch_out = 0x10, f_unstructured_targ = 0x20, f_mark = 0x80, f_mark2 = 0x100, f_entry_point = 0x200, f_interior_gotoout = 0x400, f_interior_gotoin = 0x800, f_label_bumpup = 0x1000, f_donothing_loop = 0x2000, f_dead = 0x4000, f_whiledo_overflow = 0x8000, f_flip_path = 0x10000, f_joined_block = 0x20000, f_duplicate_block = 0x40000 } |
Boolean properties of blocks. More... | |
enum | edge_flags { f_goto_edge = 1, f_loop_edge = 2, f_defaultswitch_edge = 4, f_irreducible = 8, f_tree_edge = 0x10, f_forward_edge = 0x20, f_cross_edge = 0x40, f_back_edge = 0x80, f_loop_exit_edge = 0x100 } |
Boolean properties on edges. More... | |
Public Member Functions | |
FlowBlock (void) | |
Construct a block with no edges. | |
virtual | ~FlowBlock (void) |
Destructor. | |
int4 | getIndex (void) const |
Get the index assigned to this block. | |
FlowBlock * | getParent (void) |
Get the parent FlowBlock of this. | |
FlowBlock * | getImmedDom (void) const |
Get the immediate dominator FlowBlock. | |
FlowBlock * | getCopyMap (void) const |
Get the mapped FlowBlock. | |
const FlowBlock * | getParent (void) const |
Get the parent FlowBlock of this. | |
uint4 | getFlags (void) const |
Get the block_flags properties. | |
virtual Address | getStart (void) const |
Get the starting address of code in this FlowBlock. | |
virtual Address | getStop (void) const |
Get the ending address of code in this FlowBlock. | |
virtual block_type | getType (void) const |
Get the FlowBlock type of this. | |
virtual FlowBlock * | subBlock (int4 i) const |
Get the i-th component block. | |
virtual void | markUnstructured (void) |
Mark target blocks of any unstructured edges. | |
virtual void | markLabelBumpUp (bool bump) |
Let hierarchical blocks steal labels of their (first) components. More... | |
virtual void | scopeBreak (int4 curexit, int4 curloopexit) |
Mark unstructured edges that should be breaks. | |
virtual void | printHeader (ostream &s) const |
Print a simple description of this to stream. More... | |
virtual void | printTree (ostream &s, int4 level) const |
Print tree structure of any blocks owned by this. More... | |
virtual void | printRaw (ostream &s) const |
Print raw instructions contained in this FlowBlock. | |
virtual void | emit (PrintLanguage *lng) const |
Emit the instructions in this FlowBlock as structured code. More... | |
virtual const FlowBlock * | getExitLeaf (void) const |
Get the FlowBlock to which this block exits. | |
virtual PcodeOp * | lastOp (void) const |
Get the last PcodeOp executed by this FlowBlock. | |
virtual bool | negateCondition (bool toporbottom) |
Flip the condition computed by this. More... | |
virtual bool | preferComplement (Funcdata &data) |
Rearrange this hierarchy to simplify boolean expressions. More... | |
virtual FlowBlock * | getSplitPoint (void) |
Get the leaf splitting block. More... | |
virtual int4 | flipInPlaceTest (vector< PcodeOp * > &fliplist) const |
Test normalizing the conditional branch in this. More... | |
virtual void | flipInPlaceExecute (void) |
Perform the flip to normalize conditional branch executed by this block. More... | |
virtual bool | isComplex (void) const |
Is this too complex to be a condition (BlockCondition) | |
virtual FlowBlock * | nextFlowAfter (const FlowBlock *bl) const |
Get the leaf FlowBlock that will execute after the given FlowBlock. More... | |
virtual void | finalizePrinting (const Funcdata &data) const |
Make any final configurations necessary to print the block. | |
virtual void | saveXmlHeader (ostream &s) const |
Save basic information as XML attributes. More... | |
virtual void | restoreXmlHeader (const Element *el) |
Restore basic information for XML attributes. More... | |
virtual void | saveXmlBody (ostream &s) const |
Save detail about components to an XML stream. | |
virtual void | restoreXmlBody (List::const_iterator &iter, List::const_iterator enditer, BlockMap &resolver) |
Restore details about this FlowBlock from an XML stream. More... | |
void | saveXmlEdges (ostream &s) const |
Save edge information to an XML stream. More... | |
void | restoreXmlEdges (List::const_iterator &iter, List::const_iterator enditer, BlockMap &resolver) |
Restore edges from an XML stream. More... | |
void | saveXml (ostream &s) const |
Write out this to an XML stream. More... | |
void | restoreXml (const Element *el, BlockMap &resolver) |
Restore this from an XML stream. More... | |
const FlowBlock * | nextInFlow (void) const |
Return next block to be executed in flow. More... | |
void | setVisitCount (int4 i) |
Set the number of times this block has been visited. | |
int4 | getVisitCount (void) const |
Get the count of visits. | |
void | setGotoBranch (int4 i) |
Mark a goto branch. More... | |
void | setDefaultSwitch (int4 i) |
Mark an edge as the switch default. | |
bool | isMark (void) const |
Return true if this block has been marked. | |
void | setMark (void) |
Mark this block. | |
void | clearMark (void) |
Clear any mark on this block. | |
void | setDonothingLoop (void) |
Label this as a do nothing loop. | |
void | setDead (void) |
Label this as dead. | |
bool | hasSpecialLabel (void) const |
Return true if this uses a different label. | |
bool | isJoined (void) const |
Return true if this is a joined basic block. | |
bool | isDuplicated (void) const |
Return true if this is a duplicated block. | |
void | setLoopExit (int4 i) |
Label the edge exiting this as a loop. | |
void | clearLoopExit (int4 i) |
Clear the loop exit edge. | |
void | setBackEdge (int4 i) |
Label the back edge of a loop. | |
bool | getFlipPath (void) const |
Have out edges been flipped. | |
bool | isJumpTarget (void) const |
Return true if non-fallthru jump flows into this. More... | |
FlowBlock * | getFalseOut (void) const |
Get the false output FlowBlock. | |
FlowBlock * | getTrueOut (void) const |
Get the true output FlowBlock. | |
FlowBlock * | getOut (int4 i) |
Get the i-th output FlowBlock. | |
const FlowBlock * | getOut (int4 i) const |
Get i-th output FlowBlock. | |
int4 | getOutRevIndex (int4 i) const |
Get the input index of the i-th output FlowBlock. | |
FlowBlock * | getIn (int4 i) |
Get the i-th input FlowBlock. | |
const FlowBlock * | getIn (int4 i) const |
Get the i-th input FlowBlock. | |
int4 | getInRevIndex (int4 i) const |
Get the output index of the i-th input FlowBlock. | |
const FlowBlock * | getFrontLeaf (void) const |
Get the first leaf FlowBlock. More... | |
FlowBlock * | getFrontLeaf (void) |
Get the first leaf FlowBlock. More... | |
int4 | calcDepth (const FlowBlock *leaf) const |
Get the depth of the given component FlowBlock. More... | |
bool | dominates (const FlowBlock *subBlock) const |
Does this block dominate the given block. More... | |
bool | restrictedByConditional (const FlowBlock *cond) const |
Check if the condition from the given block holds for this block. More... | |
int4 | sizeOut (void) const |
Get the number of out edges. | |
int4 | sizeIn (void) const |
Get the number of in edges. | |
bool | hasLoopIn (void) const |
Is there a looping edge coming into this block. More... | |
bool | hasLoopOut (void) const |
Is there a looping edge going out of this block. More... | |
bool | isLoopIn (int4 i) const |
Is the i-th incoming edge a loop edge. | |
bool | isLoopOut (int4 i) const |
Is the i-th outgoing edge a loop edge. | |
int4 | getInIndex (const FlowBlock *bl) const |
Get the incoming edge index for the given FlowBlock. More... | |
int4 | getOutIndex (const FlowBlock *bl) const |
Get the outgoing edge index for the given FlowBlock. More... | |
bool | isDefaultBranch (int4 i) const |
Is the i-th out edge the switch default edge. | |
bool | isLabelBumpUp (void) const |
Are labels for this printed by the parent. | |
bool | isUnstructuredTarget (void) const |
Is this the target of an unstructured goto. | |
bool | isInteriorGotoTarget (void) const |
Is there an unstructured goto to this block's interior. | |
bool | hasInteriorGoto (void) const |
Is there an unstructured goto out of this block's interior. | |
bool | isEntryPoint (void) const |
Is the entry point of the function. | |
bool | isSwitchOut (void) const |
Is this a switch block. | |
bool | isDonothingLoop (void) const |
Is this a do nothing block. | |
bool | isDead (void) const |
Is this block dead. | |
bool | isTreeEdgeIn (int4 i) const |
Is the i-th incoming edge part of the spanning tree. | |
bool | isBackEdgeIn (int4 i) const |
Is the i-th incoming edge a back edge. | |
bool | isBackEdgeOut (int4 i) const |
Is the i-th outgoing edge a back edge. | |
bool | isIrreducibleOut (int4 i) const |
Is the i-th outgoing edge an irreducible edge. | |
bool | isIrreducibleIn (int4 i) const |
Is the i-th incoming edge an irreducible edge. | |
bool | isDecisionOut (int4 i) const |
Can this and the i-th output be merged into a BlockIf or BlockList. | |
bool | isDecisionIn (int4 i) const |
Can this and the i-th input be merged into a BlockIf or BlockList. | |
bool | isLoopDAGOut (int4 i) const |
Is the i-th outgoing edge part of the DAG sub-graph. | |
bool | isLoopDAGIn (int4 i) const |
Is the i-th incoming edge part of the DAG sub-graph. | |
bool | isGotoIn (int4 i) const |
Is the i-th incoming edge unstructured. | |
bool | isGotoOut (int4 i) const |
Is the i-th outgoing edge unstructured. | |
JumpTable * | getJumptable (void) const |
Get the JumpTable associated this block. More... | |
Static Public Member Functions | |
static block_type | nameToType (const string &name) |
Get the block_type associated with a name string. More... | |
static string | typeToName (block_type bt) |
Get the name string associated with a block_type. More... | |
static bool | compareBlockIndex (const FlowBlock *bl1, const FlowBlock *bl2) |
Compare FlowBlock by index. More... | |
static bool | compareFinalOrder (const FlowBlock *bl1, const FlowBlock *bl2) |
Final FlowBlock comparison. More... | |
static FlowBlock * | findCommonBlock (FlowBlock *bl1, FlowBlock *bl2) |
Find the common dominator of two FlowBlocks. More... | |
static FlowBlock * | findCommonBlock (const vector< FlowBlock * > &blockSet) |
Find common dominator of multiple FlowBlocks. More... | |
Protected Member Functions | |
void | setFlag (uint4 fl) |
Set a boolean property. | |
void | clearFlag (uint4 fl) |
Clear a boolean property. | |
Private Member Functions | |
void | addInEdge (FlowBlock *b, uint4 lab) |
Add an edge coming into this. More... | |
void | restoreNextInEdge (const Element *el, BlockMap &resolver) |
Restore the next input edge from XML. More... | |
void | halfDeleteInEdge (int4 slot) |
Delete the in half of an edge, correcting indices. More... | |
void | halfDeleteOutEdge (int4 slot) |
Delete the out half of an edge, correcting indices. More... | |
void | removeInEdge (int4 slot) |
Remove an incoming edge. More... | |
void | removeOutEdge (int4 slot) |
Remove an outgoing edge. More... | |
void | replaceInEdge (int4 num, FlowBlock *b) |
Make an incoming edge flow from a given block. More... | |
void | replaceOutEdge (int4 num, FlowBlock *b) |
Make an outgoing edge flow to a given block. More... | |
void | replaceEdgesThru (int4 in, int4 out) |
Remove this from flow between two blocks. More... | |
void | swapEdges (void) |
Swap the first and second out edges. | |
void | setOutEdgeFlag (int4 i, uint4 lab) |
Apply an out edge label. More... | |
void | clearOutEdgeFlag (int4 i, uint4 lab) |
Remove an out edge label. More... | |
void | eliminateInDups (FlowBlock *bl) |
Eliminate duplicate in edges from given block. More... | |
void | eliminateOutDups (FlowBlock *bl) |
Eliminate duplicate out edges to given block. More... | |
void | dedup (void) |
Eliminate duplicate edges. | |
void | replaceUsingMap (void) |
Update references to other blocks using getCopyMap() More... | |
Static Private Member Functions | |
static void | replaceEdgeMap (vector< BlockEdge > &vec) |
Update block references in edges with copy map. More... | |
static void | findDups (const vector< BlockEdge > &ref, vector< FlowBlock * > &duplist) |
Find blocks that are at the end of multiple edges. More... | |
Private Attributes | |
uint4 | flags |
Collection of block_flags. | |
FlowBlock * | parent |
The parent block to which this belongs. | |
FlowBlock * | immed_dom |
Immediate dominating block. | |
FlowBlock * | copymap |
Back reference to a BlockCopy of this. | |
int4 | index |
Reference index for this block (reverse post order) | |
int4 | visitcount |
A count of visits of this node for various algorithms. | |
int4 | numdesc |
Number of descendants of this block in spanning tree (+1) | |
vector< BlockEdge > | intothis |
Blocks which (can) fall into this block. | |
vector< BlockEdge > | outofthis |
Blocks into which this block (can) fall. | |
Friends | |
class | BlockGraph |
Description of a control-flow block containing PcodeOps.
This is the base class for basic blocks (BlockBasic) and the hierarchical description of structured code. At all levels, these can be viewed as a block of code (PcodeOp objects) with other blocks flowing into and out of it.
Boolean properties of blocks.
The first four flags describe attributes of the blocks primary exiting edges The f_interior_* flags do not necessarily apply to these edges. They are used with the block structure and hierarchy algorithms where unstructured jumps are removed from the list of primary edges. These flags keep track only of the existence of unstructured edges, even though they aren't listed
Boolean properties on edges.
|
private |
Add an edge coming into this.
b | is the FlowBlock coming in |
lab | is a label for the edge |
References BlockEdge::BlockEdge(), and outofthis.
Referenced by BlockGraph::addEdge().
int4 FlowBlock::calcDepth | ( | const FlowBlock * | leaf | ) | const |
Get the depth of the given component FlowBlock.
How many getParent() calls from the leaf to this
leaf | is the component FlowBlock |
References getParent().
Referenced by getInRevIndex(), BlockGoto::saveXmlBody(), BlockMultiGoto::saveXmlBody(), and BlockIf::saveXmlBody().
|
private |
Remove an out edge label.
i | is the index of the outgoing edge |
lab | is the edge label to remove |
References intothis.
Referenced by clearLoopExit(), and BlockGraph::findIrreducible().
Compare FlowBlock by index.
References getIndex().
Referenced by isGotoOut(), and BlockMap::sortList().
Final FlowBlock comparison.
Comparator for ordering the final 0-exit blocks
References PcodeOp::code(), CPUI_RETURN, getIndex(), and lastOp().
Referenced by isGotoOut().
bool FlowBlock::dominates | ( | const FlowBlock * | subBlock | ) | const |
Does this block dominate the given block.
Return true if this block dominates the given block (or is equal to it). This assumes that block indices have been set with a reverse post order so that having a smaller index is a necessary condition for dominance.
subBlock | is the given block to test against this for dominance |
References getImmedDom().
Referenced by Merge::checkCopyPair(), and getInRevIndex().
|
private |
Eliminate duplicate in edges from given block.
bl | is the given block |
References halfDeleteOutEdge(), and BlockEdge::point.
|
private |
Eliminate duplicate out edges to given block.
bl | is the given block |
References halfDeleteInEdge(), and BlockEdge::point.
|
inlinevirtual |
Emit the instructions in this FlowBlock as structured code.
This is the main entry point, at the control-flow level, for printing structured code.
lng | is the PrintLanguage that provides details of the high-level language being printed |
Reimplemented in BlockSwitch, BlockInfLoop, BlockDoWhile, BlockFor, BlockWhileDo, BlockIf, BlockCondition, BlockList, BlockMultiGoto, BlockGoto, BlockCopy, BlockBasic, and BlockGraph.
Referenced by PrintC::emitBlockCondition(), PrintC::emitBlockCopy(), PrintC::emitBlockDoWhile(), PrintC::emitBlockFor(), PrintC::emitBlockGoto(), PrintC::emitBlockIf(), PrintC::emitBlockInfLoop(), PrintC::emitBlockLs(), PrintC::emitBlockSwitch(), and PrintC::emitBlockWhileDo().
Find the common dominator of two FlowBlocks.
Within the dominator tree, find the earliest common ancestor of two FlowBlocks
bl1 | is the first FlowBlock |
bl2 | is the second |
References clearMark(), getImmedDom(), isMark(), and setMark().
Referenced by Merge::buildDominantCopy(), PcodeOp::compareOrder(), cseElimination(), and isGotoOut().
Find common dominator of multiple FlowBlocks.
Find the most immediate dominating FlowBlock of all blocks in the given set. The container must not be empty.
blockSet | is the given set of blocks |
References getImmedDom(), getIndex(), isMark(), and setMark().
|
staticprivate |
Find blocks that are at the end of multiple edges.
ref | is the list of BlockEdges to search |
duplist | will contain the list of blocks with duplicate edges |
|
inlinevirtual |
Perform the flip to normalize conditional branch executed by this block.
This reverses the outgoing edge order in the right basic blocks, but does not modify the instructions directly.
Reimplemented in BlockCondition, and BlockBasic.
Referenced by lastOp(), and BlockIf::preferComplement().
|
inlinevirtual |
Test normalizing the conditional branch in this.
Find the set of PcodeOp objects that need to be adjusted to flip the condition this FlowBlock calculates.
Return:
fliplist | will contain the PcodeOps that need to be adjusted |
Reimplemented in BlockCondition, and BlockBasic.
Referenced by BlockCondition::flipInPlaceTest(), lastOp(), and BlockIf::preferComplement().
const FlowBlock * FlowBlock::getFrontLeaf | ( | void | ) | const |
Get the first leaf FlowBlock.
Keep descending tree hierarchy, taking the front block, until we get to the bottom copy block
References getType(), and subBlock().
Referenced by BlockSwitch::addCase(), PrintC::emitAnyLabelStatement(), PrintC::emitLabel(), getInRevIndex(), BlockGoto::gotoPrints(), BlockSwitch::grabCaseBasic(), BlockGraph::markCopyBlock(), BlockGraph::nextFlowAfter(), BlockGoto::nextFlowAfter(), BlockWhileDo::nextFlowAfter(), BlockFor::nextFlowAfter(), BlockInfLoop::nextFlowAfter(), BlockSwitch::nextFlowAfter(), BlockGoto::saveXmlBody(), BlockMultiGoto::saveXmlBody(), and BlockIf::saveXmlBody().
FlowBlock * FlowBlock::getFrontLeaf | ( | void | ) |
Get the first leaf FlowBlock.
Keep descending tree hierarchy, taking the front block, until we get to the bottom copy block
References getType(), and subBlock().
int4 FlowBlock::getInIndex | ( | const FlowBlock * | bl | ) | const |
Get the incoming edge index for the given FlowBlock.
Search through incoming blocks in edge order for the given block.
bl | is the given FlowBlock |
References BlockEdge::point.
Referenced by BlockSwitch::addCase(), Funcdata::blockRemoveInternal(), Funcdata::branchRemoveInternal(), BlockSwitch::grabCaseBasic(), isLoopOut(), and BlockBasic::unblockedMulti().
JumpTable * FlowBlock::getJumptable | ( | void | ) | const |
Get the JumpTable associated this block.
If this FlowBlock was ends with a computed jump, retrieve the associated JumpTable object
References Funcdata::findJumpTable(), BlockBasic::getFuncdata(), and PcodeOp::getParent().
Referenced by BlockSwitch::BlockSwitch(), and isGotoOut().
int4 FlowBlock::getOutIndex | ( | const FlowBlock * | bl | ) | const |
Get the outgoing edge index for the given FlowBlock.
Search through outgoing blocks in edge order for the given block.
bl | is the given FlowBlock |
References BlockEdge::point.
Referenced by FloatingEdge::getCurrentEdge(), isLoopOut(), and Funcdata::nodeJoinCreateBlock().
|
inlinevirtual |
Get the leaf splitting block.
If this block ends with a conditional branch, return the deepest component block that performs the split. This component needs to be able to perform flipInPlaceTest() and flipInPlaceExecute()
Reimplemented in BlockCondition, BlockList, BlockCopy, and BlockBasic.
Referenced by BlockCondition::flipInPlaceTest(), BlockCopy::getSplitPoint(), BlockList::getSplitPoint(), lastOp(), and BlockIf::preferComplement().
|
private |
Delete the in half of an edge, correcting indices.
slot | is the index of the incoming edge being altered |
References outofthis, BlockEdge::point, and BlockEdge::reverse_index.
Referenced by eliminateOutDups(), removeOutEdge(), and replaceOutEdge().
|
private |
Delete the out half of an edge, correcting indices.
slot | is the index of the outgoing edge being altered |
References intothis, BlockEdge::point, and BlockEdge::reverse_index.
Referenced by eliminateInDups(), removeInEdge(), and replaceInEdge().
bool FlowBlock::hasLoopIn | ( | void | ) | const |
Is there a looping edge coming into this block.
References BlockEdge::label.
Referenced by RulePullsubMulti::applyOp(), and sizeIn().
bool FlowBlock::hasLoopOut | ( | void | ) | const |
Is there a looping edge going out of this block.
References BlockEdge::label.
Referenced by sizeIn().
bool FlowBlock::isJumpTarget | ( | void | ) | const |
Return true if non-fallthru jump flows into this.
return true if block is the target of a jump
References index, and BlockEdge::point.
Referenced by PrintC::emitLabelStatement(), and getFlipPath().
|
virtual |
Let hierarchical blocks steal labels of their (first) components.
bump | if true, mark that labels for this block are printed by somebody higher in hierarchy |
Reimplemented in BlockInfLoop, BlockDoWhile, BlockFor, BlockWhileDo, and BlockGraph.
Referenced by BlockGraph::markLabelBumpUp().
|
static |
Get the block_type associated with a name string.
Given a string describing a FlowBlock type, return the block_type. This is currently only used by the restoreXml() process. TODO: Fill in the remaining names and types
nm | is the name string |
Referenced by BlockMap::createBlock(), and isGotoOut().
|
virtual |
Flip the condition computed by this.
Flip the order of outgoing edges (at least). This should also affect the original op causing the condition. Note: we don't have to flip at all levels of the hierarchy only at the top and at the bottom
toporbottom | is true if this is the top outermost block of the hierarchy getting negated |
Reimplemented in BlockCondition, BlockList, BlockCopy, and BlockBasic.
Referenced by BlockBasic::flipInPlaceExecute(), lastOp(), BlockBasic::negateCondition(), BlockCopy::negateCondition(), BlockList::negateCondition(), BlockCondition::negateCondition(), CollapseStructure::ruleBlockDoWhile(), CollapseStructure::ruleBlockFor(), CollapseStructure::ruleBlockGoto(), CollapseStructure::ruleBlockIfNoExit(), CollapseStructure::ruleBlockOr(), CollapseStructure::ruleBlockProperIf(), and CollapseStructure::ruleBlockWhileDo().
Get the leaf FlowBlock that will execute after the given FlowBlock.
Within the hierarchy of this FlowBlock, assume the given FlowBlock will fall-thru in its execution at some point. Return the first leaf block (BlockBasic or BlockCopy) that will execute after the given FlowBlock completes, assuming this is a unique block.
bl | is the given FlowBlock |
Reimplemented in BlockSwitch, BlockInfLoop, BlockDoWhile, BlockFor, BlockWhileDo, BlockIf, BlockCondition, BlockMultiGoto, BlockGoto, and BlockGraph.
Referenced by BlockGoto::gotoPrints(), BlockIf::nextFlowAfter(), and BlockSwitch::nextFlowAfter().
const FlowBlock * FlowBlock::nextInFlow | ( | void | ) | const |
Return next block to be executed in flow.
If there are two branches, pick the fall-thru branch
References PcodeOp::code(), CPUI_CBRANCH, and PcodeOp::isFallthruTrue().
Referenced by PrintC::emitBlockLs(), and restoreXmlBody().
|
inlinevirtual |
Rearrange this hierarchy to simplify boolean expressions.
For the instructions in this block, decide if the control-flow structure can be rearranged so that boolean expressions come out more naturally.
data | is the function to analyze |
Reimplemented in BlockIf.
Referenced by ActionPreferComplement::apply(), and lastOp().
|
virtual |
Print a simple description of this to stream.
Only print a header for this single block
s | is the output stream |
Reimplemented in BlockSwitch, BlockInfLoop, BlockDoWhile, BlockFor, BlockWhileDo, BlockIf, BlockCondition, BlockList, BlockMultiGoto, BlockGoto, BlockCopy, and BlockBasic.
Referenced by BlockBasic::printHeader(), BlockCopy::printHeader(), BlockGoto::printHeader(), BlockMultiGoto::printHeader(), BlockList::printHeader(), BlockCondition::printHeader(), BlockIf::printHeader(), BlockWhileDo::printHeader(), BlockFor::printHeader(), BlockDoWhile::printHeader(), BlockInfLoop::printHeader(), BlockSwitch::printHeader(), and scopeBreak().
|
virtual |
Print tree structure of any blocks owned by this.
Recursively print out the hierarchical structure of this FlowBlock.
s | is the output stream |
level | is the current level of indentation |
Reimplemented in BlockCopy, and BlockGraph.
Referenced by BlockGraph::printTree().
|
private |
Remove an incoming edge.
slot | is the index of the incoming edge to remove |
References halfDeleteOutEdge().
Referenced by BlockGraph::removeEdge().
|
private |
Remove an outgoing edge.
slot | is the index of the outgoing edge to remove |
References halfDeleteInEdge().
Referenced by BlockGraph::calcForwardDominator(), BlockGraph::removeFromFlow(), and BlockGraph::spliceBlock().
|
staticprivate |
Update block references in edges with copy map.
Block references are updated using the getCopyMap() reference on the original block
vec | is the list of edges whose block references should be updated |
|
private |
Remove this from flow between two blocks.
Remove edge in and out from this block, but create a new edge between the in-block and the out-block, preserving position in the in/out edge lists.
in | is the index of the incoming block |
out | is the index of the outgoing block |
References intothis, and outofthis.
Referenced by BlockGraph::removeFromFlowSplit().
|
private |
Make an incoming edge flow from a given block.
The original edge, which must exist, is replaced.
num | is the index of the incoming edge |
b | is the new incoming block |
References BlockEdge::BlockEdge(), halfDeleteOutEdge(), BlockEdge::label, outofthis, and BlockEdge::reverse_index.
Referenced by BlockGraph::moveOutEdge(), and BlockGraph::selfIdentify().
|
private |
Make an outgoing edge flow to a given block.
The original edge, which must exist is replaced.
num | is the index of the outgoing edge |
b | is the new outgoing block |
References BlockEdge::BlockEdge(), halfDeleteInEdge(), intothis, BlockEdge::label, and BlockEdge::reverse_index.
Referenced by BlockGraph::removeFromFlow(), BlockGraph::selfIdentify(), and BlockGraph::switchEdge().
|
private |
Update references to other blocks using getCopyMap()
Run through incoming and outgoing edges and replace FlowBlock references with the FlowBlock accessed via the getCopyMap() method.
Restore the next input edge from XML.
el | is the <edge> element |
resolver | is used to resolve block references |
References BlockEdge::BlockEdge(), BlockEdge::label, BlockEdge::point, BlockEdge::restoreXml(), and BlockEdge::reverse_index.
Restore this from an XML stream.
Recover this and all it sub-components from an XML <block> tag.
This will construct all the sub-components using resolver as a factory.
el | is the root XML element |
resolver | acts as a factory and resolves cross-references |
References Element::getChildren().
Referenced by BlockGraph::restoreXml(), and BlockGraph::restoreXmlBody().
|
inlinevirtual |
Restore details about this FlowBlock from an XML stream.
iter | is an iterator to XML elements containing component tags etc. |
enditer | marks the end of the XML tags |
resolver | is used to recover FlowBlock objects based on XML references |
Reimplemented in BlockBasic, and BlockGraph.
References nextInFlow(), BlockEdge::restoreXml(), restoreXmlEdges(), BlockEdge::saveXml(), and saveXmlEdges().
Referenced by BlockGraph::restoreXmlBody().
void FlowBlock::restoreXmlEdges | ( | List::const_iterator & | iter, |
List::const_iterator | enditer, | ||
BlockMap & | resolver | ||
) |
Restore edges from an XML stream.
iter | is an iterator to the <edge> tags |
enditer | marks the end of the list of tags |
resolver | is used to recover FlowBlock cross-references |
References Element::getName().
Referenced by restoreXmlBody().
|
virtual |
Restore basic information for XML attributes.
el | is the XML element to pull attributes from |
References Element::getAttributeValue().
Referenced by finalizePrinting().
bool FlowBlock::restrictedByConditional | ( | const FlowBlock * | cond | ) | const |
Check if the condition from the given block holds for this block.
We assume the given block has 2 out-edges and that this block is immediately reached by one of these two edges. Some condition holds when traversing the out-edge to this, and the complement of the condition holds for traversing the other out-edge. We verify that the condition holds for this entire block. More specifically, we check that that there is no path to this through the sibling edge, where the complement of the condition holds (unless we loop back through the conditional block).
cond | is the conditional block with 2 out-edges |
References getImmedDom().
Referenced by ActionConditionalConst::apply(), ValueSetSolver::applyConstraints(), and getInRevIndex().
void FlowBlock::saveXml | ( | ostream & | s | ) | const |
Write out this to an XML stream.
Serialize this and all its sub-components as an XML <block> tag.
s | is the output stream |
Referenced by StructureGraph::rawAction().
void FlowBlock::saveXmlEdges | ( | ostream & | s | ) | const |
Save edge information to an XML stream.
Write <edge> tags to stream
s | is the output stream |
Referenced by restoreXmlBody(), and Funcdata::saveXmlTree().
|
virtual |
Save basic information as XML attributes.
s | is the output stream |
Reimplemented in BlockCondition, and BlockCopy.
References a_v_i().
Referenced by finalizePrinting(), BlockCopy::saveXmlHeader(), and BlockCondition::saveXmlHeader().
void FlowBlock::setGotoBranch | ( | int4 | i | ) |
Mark a goto branch.
This is the main entry point for marking a branch from one block to another as unstructured.
i | is the index of the outgoing edge to mark |
Referenced by CollapseStructure::checkSwitchSkips(), Funcdata::forceGoto(), getVisitCount(), CollapseStructure::markExitsAsGotos(), CollapseStructure::ruleCaseFallthru(), and CollapseStructure::selectGoto().
|
private |
Apply an out edge label.
i | is the index of the outgoing edge |
lab | is the new edge label |
References intothis.
Referenced by BlockGraph::addLoopEdge(), BlockGraph::findIrreducible(), BlockGraph::findSpanningTree(), setBackEdge(), setDefaultSwitch(), and setLoopExit().
|
static |
Get the name string associated with a block_type.
For use in serializng FlowBlocks to XML.
bt | is the block_type |
Referenced by isGotoOut(), and BlockGraph::saveXmlBody().