* commenting out itype declaration to eliminate warnings
[fw/sdcc] / src / SDCCBBlock.c
index fe26978a52b8ccaea776736b0d225988395b2bb0..5c757bca4bce7e7d2a12474e18ddbd224c87515e 100644 (file)
@@ -178,6 +178,7 @@ dumpEbbsToFileExt (int id, eBBlock ** ebbs, int count)
   FILE *of;
   int i;
   eBBlock *bb;
+  set *cseSet;
 
   if (id) {
     of=createDumpFile(id);
@@ -188,40 +189,37 @@ dumpEbbsToFileExt (int id, eBBlock ** ebbs, int count)
   for (i = 0; i < count; i++)
     {
       fprintf (of, "\n----------------------------------------------------------------\n");
-      fprintf (of, "Basic Block %d %s : loop Depth = %d noPath = %d lastinLoop = %d\n",
-              ebbs[i]->dfnum,
+      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]->noPath,
-              ebbs[i]->isLastInLoop);
-
-      if (!optimize.label4) { 
-       // this only makes sense with --nolabelopt
-       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);
-       }
-#if 0 // jwk: TODO: this can't be true
-       {
-         int d;
-         fprintf (of, "\ndominators ???: ");
-         for (d=0; d<ebbs[i]->domVect->size; d++) {
-           if (bitVectBitValue(ebbs[d]->domVect, d)) {
-             fprintf (of, "%s ", ebbs[d]->entryLabel->name);
-           }
+              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; d<ebbs[i]->domVect->size; d++) {
+         if (bitVectBitValue(ebbs[i]->domVect, d)) {
+           fprintf (of, "%s ", ebbs[d]->entryLabel->name);
          }
        }
-#endif
-       fprintf (of, "\n");
       }
+      fprintf (of, "\n");
   
       fprintf (of, "\ndefines bitVector :");
       bitVectDebugOn (ebbs[i]->defSet, of);
@@ -233,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);
     }
@@ -269,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)
@@ -688,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;