eliminated numOutEdges from BB

This commit is contained in:
Artur K 2011-12-13 20:02:21 +01:00
parent e7bf886902
commit 87d1b4411c
6 changed files with 28 additions and 25 deletions

View File

@ -26,7 +26,7 @@ private:
BB() : nodeType(0),traversed(0),start(0),length(0),
numHlIcodes(0),flg(0),
inEdges(0),
numOutEdges(0),edges(0),beenOnH(0),inEdgeCount(0),reachingInt(0),
edges(0),beenOnH(0),inEdgeCount(0),reachingInt(0),
inInterval(0),correspInt(0),liveUse(0),def(0),liveIn(0),liveOut(0),
dfsFirstNum(0),dfsLastNum(0),immedDom(0),ifFollow(0),loopType(0),latchNode(0),
numBackEdges(0),loopHead(0),loopFollow(0),caseHead(0),caseTail(0),index(0)
@ -37,13 +37,13 @@ private:
//Int numInEdges; /* Number of in edges */
public:
Int begin();
Int end();
Int rbegin();
Int rend();
ICODE &front();
ICODE &back();
size_t size();
Int begin();
Int end();
Int rbegin();
Int rend();
ICODE &front();
ICODE &back();
size_t size();
byte nodeType; /* Type of node */
int traversed; /* Boolean: traversed yet? */
Int start; /* First instruction offset */
@ -54,7 +54,7 @@ public:
/* In edges and out edges */
std::vector<BB *> inEdges; // does not own held pointers
Int numOutEdges; /* Number of out edges */
//Int numOutEdges; /* Number of out edges */
std::vector<TYPEADR_TYPE> edges;/* Array of ptrs. to out edges */
/* For interval construction */

View File

@ -22,7 +22,6 @@ BB *BB::Create(Int start, Int ip, byte nodeType, Int numOutEdges, Function *pare
pnewBB->nodeType = nodeType; /* Initialise */
pnewBB->start = start;
pnewBB->length = ip - start + 1;
pnewBB->numOutEdges = (byte)numOutEdges;
pnewBB->immedDom = NO_DOM;
pnewBB->loopHead = pnewBB->caseHead = pnewBB->caseTail =
pnewBB->latchNode= pnewBB->loopFollow = NO_NODE;
@ -57,9 +56,9 @@ void BB::display()
{
printf("\nnode type = %s, ", s_nodeType[nodeType]);
printf("start = %ld, length = %ld, #out edges = %ld\n",
start, length, numOutEdges);
start, length, edges.size());
for (int i = 0; i < numOutEdges; i++)
for (int i = 0; i < edges.size(); i++)
printf(" outEdge[%2d] = %ld\n",i, edges[i].BBptr->start);
}
/*****************************************************************************
@ -73,7 +72,7 @@ void BB::displayDfs()
printf("node type = %s, ", s_nodeType[nodeType]);
printf("start = %ld, length = %ld, #in-edges = %ld, #out-edges = %ld\n",
start, length, inEdges.size(), numOutEdges);
start, length, inEdges.size(), edges.size());
printf("dfsFirst = %ld, dfsLast = %ld, immed dom = %ld\n",
dfsFirstNum, dfsLastNum,
immedDom == MAX ? -1 : immedDom);
@ -94,7 +93,7 @@ void BB::displayDfs()
printf (" inEdge[%ld] = %ld\n", i, inEdges[i]->begin());
/* Display out edges information */
for (i = 0; i < numOutEdges; i++)
for (i = 0; i < edges.size(); i++)
if (nodeType == INTERVAL_NODE)
printf(" outEdge[%ld] = %ld\n", i,
edges[i].BBptr->correspInt->numInt);
@ -103,9 +102,12 @@ void BB::displayDfs()
printf("----\n");
/* Recursive call on successors of current node */
for (i = 0; i < numOutEdges; i++)
if (edges[i].BBptr->traversed != DFS_DISP)
edges[i].BBptr->displayDfs();
std::for_each(edges.begin(), edges.end(),
[](TYPEADR_TYPE &pb)
{
if (pb.BBptr->traversed != DFS_DISP)
pb.BBptr->displayDfs();
});
}
/* Recursive procedure that writes the code for the given procedure, pointed
* to by pBB.

View File

@ -127,7 +127,7 @@ static void findEndlessFollow (Function * pProc, nodeList &loopNodes, BB * head)
nodeList::iterator p = loopNodes.begin();
for( ;p != loopNodes.end();++p)
{
for (j = 0; j < pProc->dfsLast[*p]->numOutEdges; j++)
for (j = 0; j < pProc->dfsLast[*p]->edges.size(); j++)
{
succ = pProc->dfsLast[*p]->edges[j].BBptr->dfsLastNum;
if ((! inList(loopNodes, succ)) && (succ < head->loopFollow))

View File

@ -247,7 +247,7 @@ void Function::liveRegAnalysis (dword in_liveOut)
/* liveOut(b) = U LiveIn(s); where s is successor(b)
* liveOut(b) = {liveOut}; when b is a HLI_RET node */
if (pbb->numOutEdges == 0) /* HLI_RET node */
if (pbb->edges.empty()) /* HLI_RET node */
{
pbb->liveOut = in_liveOut;
@ -265,7 +265,7 @@ void Function::liveRegAnalysis (dword in_liveOut)
}
else /* Check successors */
{
for (j = 0; j < pbb->numOutEdges; j++)
for (j = 0; j < pbb->edges.size(); j++)
pbb->liveOut |= pbb->edges[j].BBptr->liveIn;
/* propagate to invoked procedure */

View File

@ -344,7 +344,6 @@ void BB::mergeFallThrough( CIcodeRec &Icode)
nodeType = pChild->nodeType;
length = pChild->start + pChild->length - start;
Icode.ClearLlFlag(pChild->start, TARGET);
numOutEdges = pChild->numOutEdges;
edges.swap(pChild->edges);
pChild->inEdges.clear();

View File

@ -19,8 +19,10 @@ static Int numInt; /* Number of intervals */
#define nonEmpty(q) (q != NULL)
/* Returns whether the queue q is empty or not */
#define trivialGraph(G) (G->numOutEdges == 0)
bool trivialGraph(BB *G)
{
return G->edges.empty();
}
/* Returns whether the graph is a trivial graph or not */
@ -297,7 +299,7 @@ bool Function::nextOrderGraph (derSeq *derivedGi)
curr = new_entry.Gi = bbs.front();
for(auto curr=bbs.begin(); curr!=bbs.end(); ++curr)
{
for (i = 0; i < (*curr)->numOutEdges; i++)
for (i = 0; i < (*curr)->edges.size(); i++)
{
BBnode = new_entry.Gi; /* BB of an interval */
TYPEADR_TYPE &edge=(*curr)->edges[i];