* src/SDCCicode.h,
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 23 Sep 2004 05:11:43 +0000 (05:11 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 23 Sep 2004 05:11:43 +0000 (05:11 +0000)
* src/SDCCicode.c (isiCodeInFunctionCall),
* src/avr/ralloc.c (selectSpil),
* src/pic/ralloc.c (selectSpil),
* src/pic16/ralloc.c (selectSpil),
* src/ds390/ralloc.c (selectSpil),
* src/hc08/ralloc.c (selectSpil),
* src/xa51/ralloc.c (selectSpil),
* src/mcs51/ralloc.c (selectSpil): Don't use remainSpil to spill to the
stack in the middle of a function call sequence (fixes bug #1020268)
* src/SDCCicode.c (geniCodeJumpTable): fixed error in computing the
costs associated with the minimum switch case.

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3505 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCicode.c
src/SDCCicode.h
src/avr/ralloc.c
src/ds390/ralloc.c
src/hc08/ralloc.c
src/mcs51/ralloc.c
src/pic/ralloc.c
src/pic16/ralloc.c
src/xa51/ralloc.c

index 9f001e7c8195b38844c5db1ff815c0f2cfbc79f4..aff7f576c50976239c5d8115f4829b2f537080f2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2004-09-23 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/SDCCicode.h,
+       * src/SDCCicode.c (isiCodeInFunctionCall),
+       * src/avr/ralloc.c (selectSpil),
+       * src/pic/ralloc.c (selectSpil),
+       * src/pic16/ralloc.c (selectSpil),
+       * src/ds390/ralloc.c (selectSpil),
+       * src/hc08/ralloc.c (selectSpil),
+       * src/xa51/ralloc.c (selectSpil),
+       * src/mcs51/ralloc.c (selectSpil): Don't use remainSpil to spill to the
+       stack in the middle of a function call sequence (fixes bug #1020268)
+       * src/SDCCicode.c (geniCodeJumpTable): fixed error in computing the
+       costs associated with the minimum switch case.
+
 2004-09-19 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
 
        * src/SDCC.lex: fixed bug #1030549
index 6c217d45e877fdd39153fae05a377de9aef4d8d5..fb6c022406a892c1c8c123b46309ac21db456d00 100644 (file)
@@ -399,6 +399,9 @@ PRINTFUNC (picGenericOne)
   if (ic->op == SEND || ic->op == RECEIVE) {
       fprintf(of,"{argreg = %d}",ic->argreg);
   }
+  if (ic->op == IPUSH) {
+      fprintf(of,"{parmPush = %d}",ic->parmPush);
+  }
   fprintf (of, "\n");
 }
 
@@ -1039,6 +1042,40 @@ isOclsExpensive (struct memmap *oclass)
   return IN_FARSPACE (oclass);
 }
 
+/*-----------------------------------------------------------------*/
+/* isiCodeInFunctionCall - return TRUE if an iCode is between a    */
+/*   CALL/PCALL and the first IPUSH/SEND associated with the call  */
+/*-----------------------------------------------------------------*/
+int
+isiCodeInFunctionCall (iCode * ic)
+{
+  iCode * lic = ic;
+  
+  /* Find the next CALL/PCALL */
+  while (lic)
+    {
+      if (lic->op == CALL || lic->op == PCALL)
+        break;
+      lic = lic->next;
+    }
+  
+  if (!lic)
+    return FALSE;
+
+  /* A function call was found. Scan backwards and see if an */
+  /* IPUSH or SEND is encountered */
+  while (ic)
+    {
+      if (lic != ic && (ic->op == CALL || ic->op == PCALL))
+        return FALSE;
+      if (ic->op == SEND || (ic->op == IPUSH && ic->parmPush))
+        return TRUE;
+      ic = ic->prev;
+    }
+  
+  return FALSE;
+}
+
 /*-----------------------------------------------------------------*/
 /* operandLitValue - literal value of an operand                   */
 /*-----------------------------------------------------------------*/
@@ -3491,7 +3528,7 @@ geniCodeJumpTable (operand * cond, value * caseVals, ast * tree)
   int needRangeCheck = !optimize.noJTabBoundary
                        || tree->values.switchVals.swDefault;
   sym_link *cetype = getSpec (operandType (cond));
-  int sizeofMinCost, sizeofMaxCost;
+  int sizeofMinCost, sizeofZeroMinCost, sizeofMaxCost;
   int sizeofMatchJump, sizeofJumpTable;
   int sizeIndex;
 
@@ -3527,11 +3564,14 @@ geniCodeJumpTable (operand * cond, value * caseVals, ast * tree)
   
   /* Compute the size cost of the range check and subtraction. */
   sizeofMinCost = 0;
+  sizeofZeroMinCost = 0;
   sizeofMaxCost = 0;
   if (needRangeCheck)
     {
       if (!(min==0 && IS_UNSIGNED (cetype)))
         sizeofMinCost = port->jumptableCost.sizeofRangeCompare[sizeIndex];
+      if (!IS_UNSIGNED (cetype))
+        sizeofZeroMinCost = port->jumptableCost.sizeofRangeCompare[sizeIndex];
       sizeofMaxCost = port->jumptableCost.sizeofRangeCompare[sizeIndex];
     }
   if (min)
@@ -3540,11 +3580,18 @@ geniCodeJumpTable (operand * cond, value * caseVals, ast * tree)
   /* If the size cost of handling a non-zero minimum exceeds the */
   /* cost of extending the range down to zero, then it might be */
   /* better to extend the range to zero. */
-  if (min > 0 && sizeofMinCost >= (min * port->jumptableCost.sizeofElement))
+  if (min > 0 && (sizeofMinCost-sizeofZeroMinCost)
+                 >= (min * port->jumptableCost.sizeofElement))
     {
       /* Only extend the jump table if it would still be manageable. */
       if (1 + max <= port->jumptableCost.maxCount)
-        min = 0;
+        {
+          min = 0;
+          if (IS_UNSIGNED (cetype))
+            sizeofMinCost = 0;
+          else
+            sizeofMinCost = port->jumptableCost.sizeofRangeCompare[sizeIndex];
+        }
     }
     
   /* Compute the total size cost of a jump table. */
@@ -3554,7 +3601,7 @@ geniCodeJumpTable (operand * cond, value * caseVals, ast * tree)
 
   /* Compute the total size cost of a match & jump sequence */
   sizeofMatchJump = cnt * port->jumptableCost.sizeofMatchJump[sizeIndex];
-  
+
   /* If the size cost of the jump table is uneconomical then exit */
   if (sizeofMatchJump <  sizeofJumpTable)
     return 0;
index e5dbe9d8b542e1a6dae10ece03a81e3e9276935b..98469dba845b4cca33b707b6acd2ab2865adc58a 100644 (file)
@@ -326,6 +326,7 @@ operand *opFromOpWithDU (operand *, bitVect *, bitVect *);
 iCode *copyiCode (iCode *);
 operand *newiTempFromOp (operand *);
 iCode *getBuiltinParms (iCode *,int *, operand **);
+int isiCodeInFunctionCall (iCode *);
 /*-----------------------------------------------------------------*/
 /* declaration of exported variables                               */
 /*-----------------------------------------------------------------*/
index 706ae3cefffb6905e65da6b653189803a4996782..4724d789f1f6ea5f6c65a52cd5ca7dd81af64b8d 100644 (file)
@@ -901,7 +901,8 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym)
                /* check if there are any live ranges that not
                   used in the remainder of the block */
                if (!_G.blockSpil &&
-                   (selectS =
+                   !isiCodeInFunctionCall (ic) &&
+                    (selectS =
                     liveRangesWith (lrcs, notUsedInRemaining, ebp, ic))) {
                        sym = leastUsedLR (selectS);
                        if (sym != forSym) {
index e75a587f0ac15910ed4913a3b5703817ff9e1092..def06af2e1a9e36dcb04af4227b3db8a0a17ec9f 100644 (file)
@@ -685,7 +685,9 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym)
 
       /* check if there are any live ranges that not
          used in the remainder of the block */
-      if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+      if (!_G.blockSpil &&
+          !isiCodeInFunctionCall (ic) &&       
+          (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
         {
           sym = leastUsedLR (selectS);
           if (sym != forSym)
index a4dc8526695e6d8fe730c6b18078e2b05866e6a8..175f83dd3c698b25054632a10973bbf9b300bc37 100644 (file)
@@ -738,7 +738,9 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym)
 
       /* check if there are any live ranges that not
          used in the remainder of the block */
-      if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+      if (!_G.blockSpil &&
+          !isiCodeInFunctionCall (ic) &&       
+          (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
        {
          sym = leastUsedLR (selectS);
          if (sym != forSym)
index 0d4181a290ab9b7d1c8af1ff56d42a8d0e747c36..5ec469bab7a86bc72b1b541145d1393d8ed58151 100644 (file)
@@ -620,6 +620,8 @@ spillThis (symbol * sym)
   return;
 }
 
+
+
 /*-----------------------------------------------------------------*/
 /* selectSpil - select a iTemp to spil : rather a simple procedure */
 /*-----------------------------------------------------------------*/
@@ -675,7 +677,9 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym)
 
       /* check if there are any live ranges that not
          used in the remainder of the block */
-      if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+      if (!_G.blockSpil &&
+          !isiCodeInFunctionCall (ic) &&
+          (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
         {
           sym = leastUsedLR (selectS);
           if (sym != forSym)
index fcf1260820594cd05fc0c2d6948f3ee2f1b5c0f5..8768063076bde877b92e2202bf582b39ef62f1eb 100644 (file)
@@ -1800,7 +1800,9 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym)
                
                /* check if there are any live ranges that not
                used in the remainder of the block */
-               if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+               if (!_G.blockSpil &&
+                   !isiCodeInFunctionCall (ic) &&
+                   (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
                {
                        sym = leastUsedLR (selectS);
                        if (!sym->remat)
index d06ecc89a4e980de5e9a7f86ac21a9dcd5aff5b8..3e6c3f03a28a04749418e26b194c3db6bfcf797d 100644 (file)
@@ -1734,7 +1734,9 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym)
 
       /* check if there are any live ranges that not
          used in the remainder of the block */
-      if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+      if (!_G.blockSpil &&
+          !isiCodeInFunctionCall (ic) &&       
+          (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
        {
          sym = leastUsedLR (selectS);
          if (!sym->remat)
index 27c88a44f9127195957d2347e000a319039b8725..364895bdc6fd87f2489d0e3d447dc37a3414ce36 100755 (executable)
@@ -655,7 +655,9 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym)
       
       /* check if there are any live ranges that not
          used in the remainder of the block */
-      if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
+      if (!_G.blockSpil &&
+          !isiCodeInFunctionCall (ic) &&       
+          (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic)))
        {
          sym = leastUsedLR (selectS);
          if (sym != forSym)