16 #ifndef __BLOCK_ACTION__ 17 #define __BLOCK_ACTION__ 46 vector<FlowBlock *> tails;
50 list<FloatingEdge> exitedges;
52 void extendToContainer(
const LoopBody &container,vector<FlowBlock *> &body)
const;
59 void findBase(vector<FlowBlock *> &body);
60 void extend(vector<FlowBlock *> &body)
const;
61 void findExit(
const vector<FlowBlock *> &body);
62 void orderTails(
void);
63 void labelExitEdges(
const vector<FlowBlock *> &body);
64 void labelContainments(
const vector<FlowBlock *> &body,
const vector<LoopBody *> &looporder);
65 void emitLikelyEdges(list<FloatingEdge> &likely,
FlowBlock *graph);
69 static void mergeIdenticalHeads(vector<LoopBody *> &looporder);
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);
176 void initialize(
void);
177 void pushBranches(
void);
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);
223 void collapseAll(
void);
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);
323 static void gatherReturnGotos(
FlowBlock *parent,vector<FlowBlock *> &vec);
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:288
Description of a control-flow block containing PcodeOps.
Definition: block.hh:60
ActionNodeJoin(const string &g)
Constructor.
Definition: blockaction.hh:337
Structure control-flow using standard high-level code constructs.
Definition: blockaction.hh:296
FlowBlock * getCurrentEdge(int4 &outedge, FlowBlock *graph)
Get the current form of the edge.
Definition: blockaction.cc:25
The list of groups defining a root Action.
Definition: action.hh:29
Algorithm for selecting unstructured edges based an Directed Acyclic Graphs (DAG) ...
Definition: blockaction.hh:94
Container for data structures associated with a single function.
Definition: funcdata.hh:45
ActionFinalStructure(const string &g)
Constructor.
Definition: blockaction.hh:311
ActionBlockStructure(const string &g)
Constructor.
Definition: blockaction.hh:298
bool contains(const string &nm) const
Check if this ActionGroupList contains a given group.
Definition: action.hh:37
Class for holding an edge while the underlying graph is being manipulated.
Definition: blockaction.hh:29
void addRoot(FlowBlock *root)
Add a root FlowBlock to the trace.
Definition: blockaction.hh:175
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:272
void setFinishBlock(FlowBlock *bl)
Mark an exit point not to trace beyond.
Definition: blockaction.hh:178
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:327
Large scale transformations applied to the varnode/op graph.
Definition: action.hh:50
bool operator<(const LoopBody &op2) const
Order loop bodies by depth.
Definition: blockaction.hh:68
Lowest level operation of the p-code language.
Definition: op.hh:58
FlowBlock * getBottom(void) const
Get the ending FlowBlock.
Definition: blockaction.hh:35
Action, Rule, and other associates classes supporting transformations on function data-flow...
Perform final organization of the control-flow structure.
Definition: blockaction.hh:309
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:312
FlowBlock * getHead(void) const
Return the head FlowBlock of the loop.
Definition: blockaction.hh:55
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:299
ActionReturnSplit(const string &g)
Constructor.
Definition: blockaction.hh:326
FloatingEdge(FlowBlock *t, FlowBlock *b)
Construct given end points.
Definition: blockaction.hh:33
A control-flow block built out of sub-components.
Definition: block.hh:270
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
Split the epilog code of the function.
Definition: blockaction.hh:322
A basic block for p-code operations.
Definition: block.hh:363
LoopBody(FlowBlock *h)
Construct with a loop head.
Definition: blockaction.hh:54
Flip conditional control-flow so that preferred comparison operators are used.
Definition: blockaction.hh:269
int4 getChangeCount(void) const
Get number of data-flow changes.
Definition: blockaction.hh:222
Build a code structure from a control-flow graph (BlockGraph).
Definition: blockaction.hh:190
FlowBlock * getExitBlock(void) const
Get the exit FlowBlock or NULL.
Definition: blockaction.hh:58
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: blockaction.hh:338
ActionPreferComplement(const string &g)
Constructor.
Definition: blockaction.hh:287
Attempt to normalize symmetric block structures.
Definition: blockaction.hh:285
Look for conditional branch expressions that have been split and rejoin them.
Definition: blockaction.hh:335
ConditionalJoin(Funcdata &fd)
Constructor.
Definition: blockaction.hh:259
A description of the body of a loop.
Definition: blockaction.hh:44
Discover and eliminate split conditions.
Definition: blockaction.hh:232
FlowBlock * getTop(void) const
Get the starting FlowBlock.
Definition: blockaction.hh:34
void addTail(FlowBlock *bl)
Add a tail to the loop.
Definition: blockaction.hh:57
ActionNormalizeBranches(const string &g)
Constructor.
Definition: blockaction.hh:271