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), BB() : nodeType(0),traversed(0),start(0),length(0),
numHlIcodes(0),flg(0), numHlIcodes(0),flg(0),
inEdges(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), inInterval(0),correspInt(0),liveUse(0),def(0),liveIn(0),liveOut(0),
dfsFirstNum(0),dfsLastNum(0),immedDom(0),ifFollow(0),loopType(0),latchNode(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) numBackEdges(0),loopHead(0),loopFollow(0),caseHead(0),caseTail(0),index(0)
@ -37,24 +37,24 @@ private:
//Int numInEdges; /* Number of in edges */ //Int numInEdges; /* Number of in edges */
public: public:
Int begin(); Int begin();
Int end(); Int end();
Int rbegin(); Int rbegin();
Int rend(); Int rend();
ICODE &front(); ICODE &front();
ICODE &back(); ICODE &back();
size_t size(); size_t size();
byte nodeType; /* Type of node */ byte nodeType; /* Type of node */
int traversed; /* Boolean: traversed yet? */ int traversed; /* Boolean: traversed yet? */
Int start; /* First instruction offset */ Int start; /* First instruction offset */
Int length; /* No. of instructions this BB */ Int length; /* No. of instructions this BB */
Int numHlIcodes; /* No. of high-level icodes */ Int numHlIcodes; /* No. of high-level icodes */
flags32 flg; /* BB flags */ flags32 flg; /* BB flags */
/* In edges and out edges */ /* In edges and out edges */
std::vector<BB *> inEdges; // does not own held pointers 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 */ std::vector<TYPEADR_TYPE> edges;/* Array of ptrs. to out edges */
/* For interval construction */ /* 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->nodeType = nodeType; /* Initialise */
pnewBB->start = start; pnewBB->start = start;
pnewBB->length = ip - start + 1; pnewBB->length = ip - start + 1;
pnewBB->numOutEdges = (byte)numOutEdges;
pnewBB->immedDom = NO_DOM; pnewBB->immedDom = NO_DOM;
pnewBB->loopHead = pnewBB->caseHead = pnewBB->caseTail = pnewBB->loopHead = pnewBB->caseHead = pnewBB->caseTail =
pnewBB->latchNode= pnewBB->loopFollow = NO_NODE; pnewBB->latchNode= pnewBB->loopFollow = NO_NODE;
@ -57,9 +56,9 @@ void BB::display()
{ {
printf("\nnode type = %s, ", s_nodeType[nodeType]); printf("\nnode type = %s, ", s_nodeType[nodeType]);
printf("start = %ld, length = %ld, #out edges = %ld\n", 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); 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("node type = %s, ", s_nodeType[nodeType]);
printf("start = %ld, length = %ld, #in-edges = %ld, #out-edges = %ld\n", 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", printf("dfsFirst = %ld, dfsLast = %ld, immed dom = %ld\n",
dfsFirstNum, dfsLastNum, dfsFirstNum, dfsLastNum,
immedDom == MAX ? -1 : immedDom); immedDom == MAX ? -1 : immedDom);
@ -94,7 +93,7 @@ void BB::displayDfs()
printf (" inEdge[%ld] = %ld\n", i, inEdges[i]->begin()); printf (" inEdge[%ld] = %ld\n", i, inEdges[i]->begin());
/* Display out edges information */ /* Display out edges information */
for (i = 0; i < numOutEdges; i++) for (i = 0; i < edges.size(); i++)
if (nodeType == INTERVAL_NODE) if (nodeType == INTERVAL_NODE)
printf(" outEdge[%ld] = %ld\n", i, printf(" outEdge[%ld] = %ld\n", i,
edges[i].BBptr->correspInt->numInt); edges[i].BBptr->correspInt->numInt);
@ -103,9 +102,12 @@ void BB::displayDfs()
printf("----\n"); printf("----\n");
/* Recursive call on successors of current node */ /* Recursive call on successors of current node */
for (i = 0; i < numOutEdges; i++) std::for_each(edges.begin(), edges.end(),
if (edges[i].BBptr->traversed != DFS_DISP) [](TYPEADR_TYPE &pb)
edges[i].BBptr->displayDfs(); {
if (pb.BBptr->traversed != DFS_DISP)
pb.BBptr->displayDfs();
});
} }
/* Recursive procedure that writes the code for the given procedure, pointed /* Recursive procedure that writes the code for the given procedure, pointed
* to by pBB. * to by pBB.

View File

@ -127,7 +127,7 @@ static void findEndlessFollow (Function * pProc, nodeList &loopNodes, BB * head)
nodeList::iterator p = loopNodes.begin(); nodeList::iterator p = loopNodes.begin();
for( ;p != loopNodes.end();++p) 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; succ = pProc->dfsLast[*p]->edges[j].BBptr->dfsLastNum;
if ((! inList(loopNodes, succ)) && (succ < head->loopFollow)) 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) = U LiveIn(s); where s is successor(b)
* liveOut(b) = {liveOut}; when b is a HLI_RET node */ * 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; pbb->liveOut = in_liveOut;
@ -265,7 +265,7 @@ void Function::liveRegAnalysis (dword in_liveOut)
} }
else /* Check successors */ 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; pbb->liveOut |= pbb->edges[j].BBptr->liveIn;
/* propagate to invoked procedure */ /* propagate to invoked procedure */

View File

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

View File

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