Ghidra Decompiler Analysis Engine
|
Go to the documentation of this file.
16 #ifndef __BLOCK_ACTION__
17 #define __BLOCK_ACTION__
34 FlowBlock *getTop(
void)
const {
return top; }
35 FlowBlock *getBottom(
void)
const {
return bottom; }
46 vector<FlowBlock *> tails;
50 list<FloatingEdge> exitedges;
52 void extendToContainer(
const LoopBody &container,vector<FlowBlock *> &body)
const;
55 FlowBlock *getHead(
void)
const {
return head; }
57 void addTail(
FlowBlock *bl) { tails.push_back(bl); }
58 FlowBlock *getExitBlock(
void)
const {
return exitblock; }
59 void findBase(vector<FlowBlock *> &body);
60 void extend(vector<FlowBlock *> &body)
const;
61 void findExit(
const vector<FlowBlock *> &body);
64 void labelContainments(
const vector<FlowBlock *> &body,
const vector<LoopBody *> &looporder);
68 bool operator<(
const LoopBody &op2)
const {
return (depth > op2.depth); }
73 static void clearMarks(vector<FlowBlock *> &body);
104 vector<BlockTrace *> paths;
107 void createTraces(
void);
110 int4 distance(BranchPoint *op2);
113 BranchPoint(BlockTrace *parenttrace);
132 list<BlockTrace *>::iterator activeiter;
133 BranchPoint *derivedbp;
135 BlockTrace(BranchPoint *t,int4 po,int4 eo);
136 BlockTrace(BranchPoint *root,int4 po,
FlowBlock *bl);
137 bool isActive(
void)
const {
return ((flags & f_active)!=0); }
138 bool isTerminal(
void)
const {
return ((flags & f_terminal)!=0); }
144 struct BadEdgeScore {
150 bool compareFinal(
const BadEdgeScore &op2)
const;
151 bool operator<(
const BadEdgeScore &op2)
const;
154 list<FloatingEdge> &likelygoto;
155 vector<FlowBlock *> rootlist;
156 vector<BranchPoint *> branchlist;
158 int4 missedactivecount;
159 list<BlockTrace *> activetrace;
160 list<BlockTrace *>::iterator current_activeiter;
162 void removeTrace(BlockTrace *trace);
163 void processExitConflict(list<BadEdgeScore>::iterator start,list<BadEdgeScore>::iterator end);
164 BlockTrace *selectBadEdge(
void);
165 void insertActive(BlockTrace *trace);
166 void removeActive(BlockTrace *trace);
167 bool checkOpen(BlockTrace *trace);
168 list<BlockTrace *>::iterator openBranch(BlockTrace *parent);
169 bool checkRetirement(BlockTrace *trace,
FlowBlock *&exitblock);
170 list<BlockTrace *>::iterator retireBranch(BranchPoint *bp,
FlowBlock *exitblock);
171 void clearVisitCount(
void);
175 void addRoot(
FlowBlock *root) { rootlist.push_back(root); }
178 void setFinishBlock(
FlowBlock *bl) { finishblock = bl; }
193 list<FloatingEdge> likelygoto;
194 list<FloatingEdge>::iterator likelyiter;
195 list<LoopBody> loopbody;
196 list<LoopBody>::iterator loopbodyiter;
198 int4 dataflow_changecount;
200 void onlyReachableFromRoot(
FlowBlock *root,vector<FlowBlock *> &body);
201 int4 markExitsAsGotos(vector<FlowBlock *> &body);
202 bool clipExtraRoots(
void);
203 void labelLoops(vector<LoopBody *> &looporder);
204 void orderLoopBodies(
void);
205 bool updateLoopBody(
void);
218 int4 collapseInternal(
FlowBlock *targetbl);
219 void collapseConditions(
void);
222 int4 getChangeCount(
void)
const {
return dataflow_changecount; }
238 bool operator<(
const MergePair &op2)
const;
252 map<MergePair,Varnode *> mergeneed;
254 void checkExitBlock(
BlockBasic *exit,int4 in1,int4 in2);
255 void cutDownMultiequals(
BlockBasic *exit,int4 in1,int4 in2);
256 void setupMultiequals(
void);
257 void moveCbranch(
void);
336 static void gatherReturnGotos(
FlowBlock *parent,vector<FlowBlock *> &vec);
FlowBlock * getCurrentBounds(FlowBlock **top, FlowBlock *graph)
Return current loop bounds (head and bottom).
Definition: blockaction.cc:90
Action(uint4 f, const string &nm, const string &g)
Base constructor for an Action.
Definition: action.cc:25
Perform final organization of the control-flow structure.
Definition: blockaction.hh:322
A control-flow block built out of sub-components.
Definition: block.hh:271
void clearExitMarks(FlowBlock *graph)
Clear the mark on all the exits to this loop.
Definition: blockaction.cc:423
void execute(void)
Execute the merge.
Definition: blockaction.cc:2082
FlowBlock * getCurrentEdge(int4 &outedge, FlowBlock *graph)
Get the current form of the edge.
Definition: blockaction.cc:25
void pushBranches(void)
Push the trace through, removing edges as necessary.
Definition: blockaction.cc:976
Description of a control-flow block containing PcodeOps.
Definition: block.hh:60
Split the epilog code of the function.
Definition: blockaction.hh:335
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:301
static int4 compare_head(LoopBody *a, FlowBlock *looptop)
Compare just the head.
Definition: blockaction.cc:482
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: blockaction.cc:2252
void labelContainments(const vector< FlowBlock * > &body, const vector< LoopBody * > &looporder)
Record any loops that body contains.
Definition: blockaction.cc:320
CollapseStructure(BlockGraph &g)
Construct given a control-flow graph.
Definition: blockaction.cc:1850
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: blockaction.cc:2105
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: blockaction.cc:2314
The list of groups defining a root Action.
Definition: action.hh:29
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:340
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: blockaction.cc:2174
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:325
Large scale transformations applied to the varnode/op graph.
Definition: action.hh:50
void labelExitEdges(const vector< FlowBlock * > &body)
Label edges that exit the loop.
Definition: blockaction.cc:263
A basic block for p-code operations.
Definition: block.hh:365
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:285
Lowest level operation of the p-code language.
Definition: op.hh:58
void initialize(void)
Create the initial BranchPoint and BlockTrace objects.
Definition: blockaction.cc:960
A description of the body of a loop.
Definition: blockaction.hh:44
void extend(vector< FlowBlock * > &body) const
Extend body (to blocks that never exit)
Definition: blockaction.cc:143
Look for conditional branch expressions that have been split and rejoin them.
Definition: blockaction.hh:348
void collapseAll(void)
Run the whole algorithm.
Definition: blockaction.cc:1857
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:312
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
void setExitMarks(FlowBlock *graph)
Mark all the exits to this loop.
Definition: blockaction.cc:409
Class for holding an edge while the underlying graph is being manipulated.
Definition: blockaction.hh:29
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:351
TraceDAG(list< FloatingEdge > &lg)
Clear the visitcount field of any FlowBlock we have modified.
Definition: blockaction.cc:944
bool contains(const string &nm) const
Check if this ActionGroupList contains a given group.
Definition: action.hh:37
Container for data structures associated with a single function.
Definition: funcdata.hh:45
bool match(BlockBasic *b1, BlockBasic *b2)
Test blocks for the merge condition.
Definition: blockaction.cc:2045
Structure control-flow using standard high-level code constructs.
Definition: blockaction.hh:309
static bool compare_ends(LoopBody *a, LoopBody *b)
Compare the head then tail.
Definition: blockaction.cc:466
void emitLikelyEdges(list< FloatingEdge > &likely, FlowBlock *graph)
Collect likely unstructured edges.
Definition: blockaction.cc:357
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: blockaction.cc:2157
Algorithm for selecting unstructured edges based an Directed Acyclic Graphs (DAG)
Definition: blockaction.hh:94
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: blockaction.cc:2128
static LoopBody * find(FlowBlock *looptop, const vector< LoopBody * > &looporder)
Find a LoopBody.
Definition: blockaction.cc:1014
void findBase(vector< FlowBlock * > &body)
Mark the body FlowBlocks of this loop.
Definition: blockaction.cc:112
Discover and eliminate split conditions.
Definition: blockaction.hh:232
Build a code structure from a control-flow graph (BlockGraph).
Definition: blockaction.hh:190
void findExit(const vector< FlowBlock * > &body)
Choose the exit block for this loop.
Definition: blockaction.cc:175
Action, Rule, and other associates classes supporting transformations on function data-flow.
void clear(void)
Clear for a new test.
Definition: blockaction.cc:2092
static void clearMarks(vector< FlowBlock * > &body)
Clear the body marks.
Definition: blockaction.cc:1032
static void mergeIdenticalHeads(vector< LoopBody * > &looporder)
Merge loop bodies that share the same head.
Definition: blockaction.cc:439
void orderTails(void)
Find preferred tail.
Definition: blockaction.cc:238
Attempt to normalize symmetric block structures.
Definition: blockaction.hh:298
Flip conditional control-flow so that preferred comparison operators are used.
Definition: blockaction.hh:282
~TraceDAG(void)
Destructor.
Definition: blockaction.cc:951