cleaned up the mess I left behind
[fw/sdcc] / src / SDCCloop.c
index ab41d772673c9c7cd60a0ab5735eb58365d74d5f..55021f34798aa1a0d80e920e8a9a29bd86e22f6a 100644 (file)
@@ -1,9 +1,3 @@
-#define LIVERANGEHUNT
-#ifdef LIVERANGEHUNT
-  #define LRH(x) x
-#else
-  #define LRH(x)
-#endif
 /*-------------------------------------------------------------------------
 
   SDCCloop.c - source file for loop detection & optimizations
@@ -159,7 +153,6 @@ loopInsert (set ** regionSet, eBBlock * block)
 {
   if (!isinSet (*regionSet, block))
     {
-      LRH(printf ("loopInsert: %s\n", block->entryLabel->name));
       addSetHead (regionSet, block);
       STACK_PUSH (regionStack, block);
     }
@@ -236,7 +229,7 @@ DEFSETFUNC (addToExitsMarkDepth)
   V_ARG (set **, exits);
   V_ARG (int, depth);
   V_ARG (region *, lr);
-  LRH(printf ("addToExitsMarkDepth: %s %d\n", ebp->entryLabel->name, depth));
+
   /* mark the loop depth of this block */
   //if (!ebp->depth)
   if (ebp->depth<depth)
@@ -272,36 +265,13 @@ DEFSETFUNC (createLoop)
   eBBlock *block;
   int dfMin = count ,dfMax =0, i;
 
-  LRH(printf("CreateLoop\n"));
   /* make sure regionStack is empty */
   while (!STACK_EMPTY (regionStack))
     STACK_POP (regionStack);
 
   /* add the entryBlock */
   addSet (&aloop->regBlocks, ep->to);
-#ifdef LIVERANGEHUNT
-  // print regBlocks jwk
-  { 
-    eBBlock *ebp;
-    region *lp=aloop;
-    for (ebp=setFirstItem(lp->regBlocks); ebp; ebp=setNextItem(lp->regBlocks)) {
-      printf ("cl1 %s ", ebp->entryLabel->name);
-    }
-    printf (" %d\n", count);
-  }
-#endif
   loopInsert (&aloop->regBlocks, ep->from);
-#ifdef LIVERANGEHUNT
-  // print regBlocks jwk
-  { 
-    eBBlock *ebp;
-    region *lp=aloop;
-    for (ebp=setFirstItem(lp->regBlocks); ebp; ebp=setNextItem(lp->regBlocks)) {
-      printf ("cl2 %s ", ebp->entryLabel->name);
-    }
-    printf (" %d\n", count);
-  }
-#endif
 
   while (!STACK_EMPTY (regionStack))
     {
@@ -311,19 +281,8 @@ DEFSETFUNC (createLoop)
        applyToSet (block->predList, insertIntoLoop, &aloop->regBlocks);
     }
 
-#ifdef LIVERANGEHUNT
-  // print regBlocks jwk
-  { 
-    eBBlock *ebp;
-    region *lp=aloop;
-    for (ebp=setFirstItem(lp->regBlocks); ebp; ebp=setNextItem(lp->regBlocks)) {
-      printf ("cl3 %s ", ebp->entryLabel->name);
-    }
-    printf (" %d\n", count);
-  }
-#endif
-
   aloop->entry = ep->to;
+
   /* set max & min dfNum for loopRegion */
   for ( block = setFirstItem(aloop->regBlocks); block; 
        block = setNextItem(aloop->regBlocks)) {
@@ -337,9 +296,10 @@ DEFSETFUNC (createLoop)
     if (ebbs[i]->dfnum > dfMin && 
           ebbs[i]->dfnum < dfMax &&
          !isinSet(aloop->regBlocks,ebbs[i])) {
-         if (!ebbs[i]->partOfLoop) ebbs[i]->partOfLoop = aloop;
+         if (!ebbs[i]->partOfLoop) {
+           ebbs[i]->partOfLoop = aloop;
+         }
       }
-    LRH(printf("****** %d %d %d %x %s\n", ebbs[i]->dfnum, dfMin, dfMax, ebbs[i]->partOfLoop, ebbs[i]->entryLabel->name));
   }
 
   /* and if this is a conditional block, the other side of the IFX 
@@ -515,7 +475,7 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
          int lin, rin;
          cseDef *ivar;
 
-         /* jwk: TODO this is only needed if the call is between
+         /* TODO this is only needed if the call is between
             here and the definition, but I am too lazy to do that now */
 
          /* if there are function calls in this block */
@@ -937,10 +897,10 @@ basicInduction (region * loopReg, eBBlock ** ebbs, int count)
                              iCode *newic = newiCode ('=', NULL,
                                        operandFromOperand (IC_RIGHT (ic)));
                              IC_RESULT (newic) = operandFromOperand (IC_RESULT (ic));
-                             OP_DEFS_SET ((IC_RESULT (newic)),
-                               bitVectSetBit (OP_DEFS (IC_RESULT (newic)), newic->key));
-                             OP_USES_SET ((IC_RIGHT (newic)),
-                               bitVectSetBit (OP_USES (IC_RIGHT (newic)), newic->key));
+                             OP_DEFS(IC_RESULT (newic))=
+                               bitVectSetBit (OP_DEFS (IC_RESULT (newic)), newic->key);
+                             OP_USES(IC_RIGHT (newic))=
+                               bitVectSetBit (OP_USES (IC_RIGHT (newic)), newic->key);
                              /* and add it */
                              if (eblock->sch && eblock->sch->op == LABEL)
                                addiCodeToeBBlock (eblock, newic, eblock->sch->next);
@@ -1154,7 +1114,7 @@ DEFSETFUNC (mergeRegions)
       if (lp->entry == theLoop->entry)
        {
          theLoop->regBlocks = unionSets (theLoop->regBlocks,
-                                         lp->regBlocks, THROW_BOTH);
+                                         lp->regBlocks, THROW_DEST);
          lp->merged = 1;
        }
     }
@@ -1217,7 +1177,6 @@ createLoopRegions (eBBlock ** ebbs, int count)
   int maxDepth = 0;
   region *lp;
 
-  LRH(printf ("createLoopRegions: %x\n", ebbs));
   /* get all the back edges in the graph */
   if (!applyToSet (graphEdges, backEdges, &bEdges))
     return 0;                  /* found no loops */
@@ -1225,18 +1184,6 @@ createLoopRegions (eBBlock ** ebbs, int count)
   /* for each of these back edges get the blocks that */
   /* constitute the loops                             */
   applyToSet (bEdges, createLoop, &allRegion, ebbs,count);
-#ifdef LIVERANGEHUNT
-  // print regBlocks
-  { 
-    eBBlock *ebp;
-    lp=setFirstItem(allRegion);
-    printf ("createLoopRegions: ");
-    for (ebp=setFirstItem(lp->regBlocks); ebp; ebp=setNextItem(lp->regBlocks)) {
-      printf ("%s ", ebp->entryLabel->name);
-    }
-    printf (" %d\n", count);
-  }
-#endif
 
   /* now we will create regions from these loops               */
   /* loops with the same entry points are considered to be the */