]> git.gag.com Git - fw/sdcc/commitdiff
fixed bug #845089
authorkflittner <kflittner@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 23 Nov 2003 12:43:30 +0000 (12:43 +0000)
committerkflittner <kflittner@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 23 Nov 2003 12:43:30 +0000 (12:43 +0000)
* src/SDCCbitv.h,
* src/SDCCbitv.c: added function to free a bitvector
* src/SDCClrange.h,
* src/SDCClrange.c: added function to recompute the liveranges
* 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,
* src/z80/ralloc.c: recompute the liveranges after register packing

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

13 files changed:
ChangeLog
src/SDCCbitv.c
src/SDCCbitv.h
src/SDCClrange.c
src/SDCClrange.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
src/z80/ralloc.c

index 63aa3a67b2eda39216476d71491dd33a1b09de1f..f9ad25cfdeac92214566abd5c1b1c290c4d9f619 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2003-11-23 Klaus Flittner <klaus_flittner@gmx.de>
+
+       fixed bug #845089
+       * src/SDCCbitv.h,
+       * src/SDCCbitv.c: added function to free a bitvector
+       * src/SDCClrange.h,
+       * src/SDCClrange.c: added function to recompute the liveranges
+       * 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,
+       * src/z80/ralloc.c: recompute the liveranges after register packing
+
 2003-11-21 Klaus Flittner <klaus_flittner@gmx.de>
 
        * src/SDCCloop.c (newInduction): fixed bug #845630
index da8c692a0ea4a4e3859a801e4b60d29149a53975..987d5bef26575bbca758de62655e4f927bff7870 100644 (file)
@@ -49,6 +49,19 @@ newBitVect (int size)
   return bvp;
 }
 
+/*-----------------------------------------------------------------*/
+/* freeBitVect - frees the memory used by the bitVector            */
+/*-----------------------------------------------------------------*/
+void
+freeBitVect (bitVect * bvp)
+{
+  if (!bvp)
+    return;
+
+  Safe_free (bvp->vect);
+  Safe_free (bvp);
+}
+
 /*-----------------------------------------------------------------*/
 /* bitVectResize - changes the size of a bit vector                */
 /*-----------------------------------------------------------------*/
index c6115cac33111d0e3b53d3bc029b79467cf2dd4d..b20744ba50771f8eb967aee9f631fb3db8fe85af 100644 (file)
@@ -44,6 +44,7 @@ extern int bitVectDefault;
 /*-----------------------------------------------------------------*/
 /* bitvector related functions */
 bitVect *newBitVect (int);
+void freeBitVect (bitVect *);
 bitVect *bitVectResize (bitVect *, int);
 bitVect *bitVectSetBit (bitVect *, int);
 void bitVectUnSetBit (bitVect *, int);
index b33428c33872323674116277bee3697e6ed326f5..58e2f61614ee5771d8bc87b2d051d8185e8623e8 100644 (file)
@@ -332,6 +332,28 @@ incUsed (iCode *ic, operand *op)
     OP_SYMBOL (op)->used += 1;
 }
 
+/*-----------------------------------------------------------------*/
+/* rliveClear - clears the rlive bitVectors                        */
+/*-----------------------------------------------------------------*/
+void
+rliveClear (eBBlock ** ebbs, int count)
+{
+  int i;
+
+  /* for all blocks do */
+  for (i = 0; i < count; i++)
+    {
+      iCode *ic;
+
+      /* for all instructions in this block do */
+      for (ic = ebbs[i]->sch; ic; ic = ic->next)
+        {
+         freeBitVect (ic->rlive);
+         ic->rlive = NULL;
+       }
+    }
+}
+
 /*-----------------------------------------------------------------*/
 /* rlivePoint - for each point compute the ranges that are alive   */
 /*-----------------------------------------------------------------*/
@@ -648,3 +670,31 @@ computeLiveRanges (eBBlock ** ebbs, int count)
   computeClash(ebbs, count);
 }
 
+/*-----------------------------------------------------------------*/
+/* recomputeLiveRanges - recomputes the live ranges for variables  */
+/*-----------------------------------------------------------------*/
+void
+recomputeLiveRanges (eBBlock ** ebbs, int count)
+{
+  symbol * sym;
+  int key;
+
+  /* clear all rlive bitVectors */
+  rliveClear (ebbs, count);
+
+  sym = hTabFirstItem (liveRanges, &key);
+  if (sym)
+    {
+      do {
+        sym->used = 0;
+        sym->liveFrom = 0;
+        sym->liveTo = 0;
+        freeBitVect (sym->clashes);
+        sym->clashes = NULL;
+      } while ( (sym = hTabNextItem (liveRanges, &key)));
+    }
+
+  /* do the LR computation again */
+  computeLiveRanges (ebbs, count);
+}
+
index 73453527baa4a5805b105d5d34b4dbc8a267cfea..a422e1f4d93b0c27fa4d701ff97047b7cee0ae38 100644 (file)
@@ -33,6 +33,7 @@ extern hTab *iCodeSeqhTab;
 int  notUsedInBlock (symbol *, eBBlock *, iCode *);
 bool allDefsOutOfRange (bitVect *, int, int);
 void computeLiveRanges (eBBlock **, int);
+void recomputeLiveRanges (eBBlock **, int);
 
 void setFromRange (operand *, int);
 void setToRange (operand *, int, bool);
index 134286c46a39b27590d36b7aa72751069844fc67..abecd394c9a2efde31e97fec66b23eb669e6b98c 100644 (file)
@@ -2230,6 +2230,10 @@ avr_assignRegisters (eBBlock ** ebbs, int count)
        for (i = 0; i < count; i++)
                packRegisters (ebbs[i]);
 
+       /* liveranges probably changed by register packing
+          so we compute them again */
+       recomputeLiveRanges (ebbs, count);
+
        if (options.dump_pack)
                dumpEbbsToFileExt (DUMP_PACK, ebbs, count);
 
index 4a18d00d0fb9282544e4c6119846ab2c513f3d93..042eb5009109fada2b0d36957caa48e67fdedada 100644 (file)
@@ -3026,6 +3026,10 @@ ds390_assignRegisters (eBBlock ** ebbs, int count)
   for (i = 0; i < count; i++)
     packRegisters (ebbs[i]);
 
+  /* liveranges probably changed by register packing
+     so we compute them again */
+  recomputeLiveRanges (ebbs, count);
+
   if (options.dump_pack)
     dumpEbbsToFileExt (DUMP_PACK, ebbs, count);
 
index 606fed3eb55360568e72a355c510896b9aa1d1fa..82abbb0f3fd9b6380ea23cef8f5c40a9c4048d0b 100644 (file)
@@ -2994,6 +2994,10 @@ hc08_assignRegisters (eBBlock ** ebbs, int count)
   for (i = 0; i < count; i++)
     packRegisters (ebbs, i);
 
+  /* liveranges probably changed by register packing
+     so we compute them again */
+  recomputeLiveRanges (ebbs, count);
+  
   if (options.dump_pack)
     dumpEbbsToFileExt (DUMP_PACK, ebbs, count);
 
index 11ddf3745f2fcc3744116e8819c41b919a72be77..163c2c54fffca23f890f0245f8650e8a1150b6ee 100644 (file)
@@ -2881,7 +2881,10 @@ mcs51_assignRegisters (eBBlock ** ebbs, int count)
   
   for (i = 0; i < count; i++)
     packRegisters (ebbs, i);
-  
+
+  /* liveranges probably changed by register packing
+     so we compute them again */
+  recomputeLiveRanges (ebbs, count);
 
   if (options.dump_pack)
     dumpEbbsToFileExt (DUMP_PACK, ebbs, count);
index 3fa1870eb889d97873f083831c9f68be08947c57..f191dd5113535d8eb51a0ef708c054302f9aa858 100644 (file)
@@ -3848,6 +3848,10 @@ pic14_assignRegisters (eBBlock ** ebbs, int count)
 
   }
 
+  /* liveranges probably changed by register packing
+     so we compute them again */
+  recomputeLiveRanges (ebbs, count);
+  
   if (options.dump_pack)
     dumpEbbsToFileExt (DUMP_PACK, ebbs, count);
 
index c2de61d9c01a42fa2a5e799a8b8ecd4c7b25920d..41de32e86ce4001abdbe2b9986b247ddc48188a0 100644 (file)
@@ -3842,6 +3842,10 @@ pic16_assignRegisters (eBBlock ** ebbs, int count)
 
   }
 
+  /* liveranges probably changed by register packing
+     so we compute them again */
+  recomputeLiveRanges (ebbs, count);
+
   if (options.dump_pack)
     dumpEbbsToFileExt (DUMP_PACK, ebbs, count);
 
index aace857961508192c0856842be04dd77724ab0f2..1f530ece925535d57c7da83b39c2841f6329e2a2 100755 (executable)
@@ -2054,7 +2054,11 @@ xa51_assignRegisters (eBBlock ** ebbs, int count)
      live ranges reducing some register pressure */
   for (i = 0; i < count; i++)
     packRegisters (ebbs[i]);
-  
+
+  /* liveranges probably changed by register packing
+     so we compute them again */
+  recomputeLiveRanges (ebbs, count);
+
   if (options.dump_pack)
     dumpEbbsToFileExt (DUMP_PACK, ebbs, count);
   
index 99513386c72a385818b9e7f2d4629024056b985a..0b7b03d327e7713dffb14240d9471d3326855311 100644 (file)
@@ -3014,6 +3014,10 @@ z80_assignRegisters (eBBlock ** ebbs, int count)
   for (i = 0; i < count; i++)
     packRegisters (ebbs[i]);
 
+  /* liveranges probably changed by register packing
+     so we compute them again */
+  recomputeLiveRanges (ebbs, count);
+
   if (options.dump_pack)
     dumpEbbsToFileExt (DUMP_PACK, ebbs, count);