Hacked const and volatile modifiers a bit.
[fw/sdcc] / src / SDCClrange.c
index 7d5646cd452abb78dca96109a73b5eb72cc329d1..33dddbad685b58a07415ef32de55c4a457d7ce7a 100644 (file)
@@ -344,7 +344,7 @@ operandLUse (operand * op, eBBlock ** ebbs,
          !IS_STATIC (etype))
        {
 
-         if (bitVectIsZero (op->usesDefs))
+         if (bitVectIsZero (op->usesDefs) && OP_SYMBOL(op)->ival==NULL)
            {
              OP_SYMBOL (op)->isspilt = 1;
 
@@ -658,6 +658,44 @@ static void computeClash ()
     }
 }
 
+/*-----------------------------------------------------------------*/
+/* allDefsOutOfRange - all definitions are out of a range          */
+/*-----------------------------------------------------------------*/
+bool
+allDefsOutOfRange (bitVect * defs, int fseq, int toseq)
+{
+  int i;
+
+  if (!defs)
+    return TRUE;
+
+  for (i = 0; i < defs->size; i++)
+    {
+      iCode *ic;
+
+      if (bitVectBitValue (defs, i) &&
+         (ic = hTabItemWithKey (iCodehTab, i)) &&
+         (ic->seq >= fseq && ic->seq <= toseq))
+
+       return FALSE;
+
+    }
+
+  return TRUE;
+}
+
+/*-----------------------------------------------------------------*/
+/* notUsedInBlock - not used in this block                         */
+/*-----------------------------------------------------------------*/
+int
+notUsedInBlock (symbol * sym, eBBlock * ebp, iCode *ic)
+{
+  return (!bitVectBitsInCommon (sym->defs, ebp->usesDefs) &&
+         allDefsOutOfRange (sym->defs, ebp->fSeq, ebp->lSeq) &&
+         allDefsOutOfRange (sym->uses, ebp->fSeq, ebp->lSeq));
+}
+
+
 /*-----------------------------------------------------------------*/
 /* computeLiveRanges - computes the live ranges for variables      */
 /*-----------------------------------------------------------------*/
@@ -687,3 +725,4 @@ computeLiveRanges (eBBlock ** ebbs, int count)
   /* compute which overlaps with what */
   computeClash();
 }
+