X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCBBlock.c;h=5c757bca4bce7e7d2a12474e18ddbd224c87515e;hb=070bd254c8d15e34a31f978d9507858ac560ddfd;hp=fd50e6a3b00b08df5a1e1715180d402c8b413c2e;hpb=cfacc9043f84988c742792b7907cb74f670589f1;p=fw%2Fsdcc diff --git a/src/SDCCBBlock.c b/src/SDCCBBlock.c index fd50e6a3..5c757bca 100644 --- a/src/SDCCBBlock.c +++ b/src/SDCCBBlock.c @@ -84,9 +84,9 @@ newEdge (eBBlock * from, eBBlock * to) } /*-----------------------------------------------------------------*/ -/* appendDumpFile - if not already created, create the dump file */ +/* createDumpFile - create the dump file */ /*-----------------------------------------------------------------*/ -FILE *appendDumpFile (int id) { +FILE *createDumpFile (int id) { struct _dumpFiles *dumpFilesPtr=dumpFiles; while (dumpFilesPtr->id) { @@ -96,7 +96,7 @@ FILE *appendDumpFile (int id) { } if (!dumpFilesPtr->id) { - fprintf (stdout, "internal error: appendDumpFile: unknown dump file.\n"); + fprintf (stdout, "internal error: createDumpFile: unknown dump file.\n"); exit (1); } @@ -121,7 +121,6 @@ void closeDumpFiles() { for (dumpFilesPtr=dumpFiles; dumpFilesPtr->id; dumpFilesPtr++) { if (dumpFilesPtr->filePtr) { fclose (dumpFilesPtr->filePtr); - //dprintf ("closed %s\n", dumpFilesPtr->ext); } } } @@ -137,7 +136,7 @@ dumpLiveRanges (int id, hTab * liveRanges) int k; if (id) { - file=appendDumpFile(id); + file=createDumpFile(id); } else { file = stdout; } @@ -178,9 +177,11 @@ dumpEbbsToFileExt (int id, eBBlock ** ebbs, int count) { FILE *of; int i; + eBBlock *bb; + set *cseSet; if (id) { - of=appendDumpFile(id); + of=createDumpFile(id); } else { of = stdout; } @@ -188,12 +189,38 @@ dumpEbbsToFileExt (int id, eBBlock ** ebbs, int count) for (i = 0; i < count; i++) { fprintf (of, "\n----------------------------------------------------------------\n"); - fprintf (of, "Basic Block %s : loop Depth(lSeq) = %d(%d) noPath = %d , lastinLoop = %d\n", + fprintf (of, "Basic Block %s (df:%d bb:%d lvl:%d): loopDepth=%d%s%s%s\n", ebbs[i]->entryLabel->name, + ebbs[i]->dfnum, ebbs[i]->bbnum, ebbs[i]->entryLabel->level, ebbs[i]->depth, - ebbs[i]->depth ? findLoopEndSeq(ebbs[i]->partOfLoop) : 0, - ebbs[i]->noPath, - ebbs[i]->isLastInLoop); + ebbs[i]->noPath ? " noPath" : "", + ebbs[i]->partOfLoop ? " partOfLoop" : "", + ebbs[i]->isLastInLoop ? " isLastInLoop" : ""); + + // a --nolabelopt makes this more readable + fprintf (of, "\nsuccessors: "); + for (bb=setFirstItem(ebbs[i]->succList); + bb; + bb=setNextItem(ebbs[i]->succList)) { + fprintf (of, "%s ", bb->entryLabel->name); + } + fprintf (of, "\npredecessors: "); + for (bb=setFirstItem(ebbs[i]->predList); + bb; + bb=setNextItem(ebbs[i]->predList)) { + fprintf (of, "%s ", bb->entryLabel->name); + } + { + int d; + fprintf (of, "\ndominators: "); + for (d=0; ddomVect->size; d++) { + if (bitVectBitValue(ebbs[i]->domVect, d)) { + fprintf (of, "%s ", ebbs[d]->entryLabel->name); + } + } + } + fprintf (of, "\n"); + fprintf (of, "\ndefines bitVector :"); bitVectDebugOn (ebbs[i]->defSet, of); fprintf (of, "\nlocal defines bitVector :"); @@ -204,6 +231,29 @@ dumpEbbsToFileExt (int id, eBBlock ** ebbs, int count) fprintf (of, "\nInductions Set bitvector :"); bitVectDebugOn (ebbs[i]->linds, of); } + + fprintf (of, "\ninExprs:"); + for (cseSet = ebbs[i]->inExprs; cseSet; cseSet=cseSet->next) { + cseDef *item=cseSet->item; + fprintf (of, " %s(%d)",OP_SYMBOL(item->sym)->name,item->diCode->key); + if (item->fromGlobal) + fprintf (of, "g"); + } + fprintf (of, "\noutExprs:"); + for (cseSet = ebbs[i]->outExprs; cseSet; cseSet=cseSet->next) { + cseDef *item=cseSet->item; + fprintf (of, " %s(%d)",OP_SYMBOL(item->sym)->name,item->diCode->key); + if (item->fromGlobal) + fprintf (of, "g"); + } + fprintf (of, "\nkilledExprs:"); + for (cseSet = ebbs[i]->killedExprs; cseSet; cseSet=cseSet->next) { + cseDef *item=cseSet->item; + fprintf (of, " %s(%d)",OP_SYMBOL(item->sym)->name,item->diCode->key); + if (item->fromGlobal) + fprintf (of, "g"); + } + fprintf (of, "\n----------------------------------------------------------------\n"); printiCChain (ebbs[i]->sch, of); } @@ -217,14 +267,14 @@ eBBlock * iCode2eBBlock (iCode * ic) { iCode *loop; - eBBlock *ebb = neweBBlock (); /* a llocate an entry */ + eBBlock *ebb = neweBBlock (); /* allocate an entry */ /* put the first one unconditionally */ ebb->sch = ic; /* if this is a label then */ if (ic->op == LABEL) - ebb->entryLabel = ic->argLabel.label; + ebb->entryLabel = ic->label; else { SNPRINTF (buffer, sizeof(buffer), "_eBBlock%d", eBBNum++); @@ -240,6 +290,14 @@ iCode2eBBlock (iCode * ic) ebb->ech = ebb->sch; return ebb; } + + /* if this is a function call */ + if (ic->op == CALL || ic->op == PCALL) + { + ebb->hasFcall = 1; + if (currFunc) + FUNC_HASFCALL(currFunc->type) = 1; + } if ((ic->next && ic->next->op == LABEL) || !ic->next) @@ -564,7 +622,7 @@ replaceSymBySym (set * sset, operand * src, operand * dest) { bitVectUnSetBit (OP_USES (IC_COND (ic)), ic->key); IC_COND (ic) = operandFromOperand (dest); - OP_USES_SET ((dest), bitVectSetBit (OP_USES (dest), ic->key)); + OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key); continue; } @@ -573,7 +631,7 @@ replaceSymBySym (set * sset, operand * src, operand * dest) bitVectUnSetBit (OP_USES (IC_RIGHT (ic)), ic->key); IC_RIGHT (ic) = operandFromOperand (dest); IC_RIGHT (ic)->isaddr = 0; - OP_USES_SET ((dest), bitVectSetBit (OP_USES (dest), ic->key)); + OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key); } if (isOperandEqual (IC_LEFT (ic), src)) @@ -589,7 +647,7 @@ replaceSymBySym (set * sset, operand * src, operand * dest) IC_LEFT (ic) = operandFromOperand (dest); IC_LEFT (ic)->isaddr = 0; } - OP_USES_SET ((dest), bitVectSetBit (OP_USES (dest), ic->key)); + OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key); } /* special case for pointer sets */ @@ -599,7 +657,7 @@ replaceSymBySym (set * sset, operand * src, operand * dest) bitVectUnSetBit (OP_USES (IC_RESULT (ic)), ic->key); IC_RESULT (ic) = operandFromOperand (dest); IC_RESULT (ic)->isaddr = 1; - OP_USES_SET ((dest), bitVectSetBit (OP_USES (dest), ic->key)); + OP_USES(dest)=bitVectSetBit (OP_USES (dest), ic->key); } } } @@ -659,13 +717,32 @@ iCodeFromeBBlock (eBBlock ** ebbs, int count) (ebbs[i]->entryLabel != entryLabel && ebbs[i]->entryLabel != returnLabel)) { - werror (W_CODE_UNREACH, ebbs[i]->sch->filename, ebbs[i]->sch->lineno); - continue; + iCode *ic = NULL; + bool foundNonlabel = 0; + ic=ebbs[i]->sch; + do + { + if (ic->op != LABEL) + { + foundNonlabel = 1; + break; + } + if (ic==ebbs[i]->ech) + break; + ic = ic->next; + } + while (ic); + if (foundNonlabel && ic) + { + werrorfl (ic->filename, ic->lineno, W_CODE_UNREACH); + continue; + } } lic->next = ebbs[i]->sch; lic->next->prev = lic; lic = ebbs[i]->ech; + } return ric;