* src/pic16/device.c (pic16_dump_usection): force udata sections
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 15 Sep 2008 09:28:11 +0000 (09:28 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 15 Sep 2008 09:28:11 +0000 (09:28 +0000)
  into the addressable range (0..0xFFF), workaround for a gpsim
  bug preventing simulation of regtest bug1750318
* src/pic16/ralloc.c (deassignLRs): cosmetic changes,
  (serialRegAssign): fixed regtest bug-971834,
  (pic16_packRegisters): avoid null-pointer dereference

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

ChangeLog
src/pic16/device.c
src/pic16/ralloc.c

index c576667e83903d7ca46b2c99513bb0e0fc1b7343..e3e936750e64a196a130065c5fb3af7e25a5f74e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-09-15 Raphael Neider <rneider AT web.de>
+
+       * src/pic16/device.c (pic16_dump_usection): force udata sections
+         into the addressable range (0..0xFFF), workaround for a gpsim
+         bug preventing simulation of regtest bug1750318
+       * src/pic16/ralloc.c (deassignLRs): cosmetic changes,
+         (serialRegAssign): fixed regtest bug-971834,
+         (pic16_packRegisters): avoid null-pointer dereference
+
 2008-09-14 Raphael Neider <rneider AT web.de>
 
        * src/pic16/gen.c, src/pic16/ralloc.c: use
index 66ee6f3c587c7f0766c56e8adfcd55f16c13f536..726e0fe941b9bacf72edb44b655ced034387dcc1 100644 (file)
@@ -195,29 +195,30 @@ void pic16_dump_usection(FILE *of, set *section, int fix)
 #endif
         } else {
           unsigned int j=0;
-          int deb_addr=0;
 
                 rprev = NULL;
-                init_addr = rlist[j]->address;
-                deb_addr = init_addr;
-                fprintf(of, "\n\nustat_%s_%02d\tudata\t0X%04X\n", moduleName, abs_usection_no++, init_addr);
+                init_addr = (rlist[j]->address & 0x0FFF); // warning(s) emitted below
+                fprintf(of, "\n\nustat_%s_%02d\tudata\t0X%04X\n", moduleName, abs_usection_no++, (init_addr & 0x0FFF));
 
                 for(j=0;j<i;j++) {
                         r = rlist[j];
                         if(j < i-1)r1 = rlist[j+1]; else r1 = NULL;
 
-                        init_addr = r->address;
-                        deb_addr = init_addr;
+                        init_addr = (r->address & 0x0FFF);
+                        if (init_addr != r->address) {
+                            fprintf (stderr, "%s: WARNING: Changed address of pinned variable %s from 0x%x to 0x%x\n",
+                                    moduleName, r->name, r->address, init_addr);
+                        } // if
 
-                        if((rprev && (init_addr > (rprev->address + rprev->size)))) {
+                        if((rprev && (init_addr != ((rprev->address & 0x0FFF) + rprev->size)))) {
                                 fprintf(of, "\n\nustat_%s_%02d\tudata\t0X%04X\n", moduleName, abs_usection_no++, init_addr);
                         }
 
-                        if(r1 && (init_addr == r1->address)) {
+                        /* XXX: Does not handle partial overlap correctly. */
+                        if(r1 && (init_addr == (r1->address & 0x0FFF))) {
                                 fprintf(of, "\n%s\tres\t0\n", r->name);
                         } else {
                                 fprintf(of, "%s\tres\t%d\n", r->name, r->size);
-                                deb_addr += r->size;
                                 statistics.udsize += r->size;
                         }
 
index b61225f3cfed53f94c506d7fdab2bd4c08546826..c626d27fcb3ed70176a2966c1c6089f4054cce21 100644 (file)
@@ -2117,12 +2117,6 @@ deassignLRs (iCode * ic, eBBlock * ebp)
             )
             {
 
-
-//            for (i = 0; i < max (sym->nRegs, result->nRegs); i++)
-              /* the above does not free the unsued registers in sym,
-               * leaving them marked as used, and increasing register usage
-               * until the end of the function - VR 23/11/05 */
-
               for (i = 0; i < result->nRegs; i++)
                 if (i < sym->nRegs)
                   result->regs[i] = sym->regs[i];
@@ -2130,6 +2124,7 @@ deassignLRs (iCode * ic, eBBlock * ebp)
                   result->regs[i] = getRegGpr (ic, ebp, result);
 
               _G.regAssigned = bitVectSetBit (_G.regAssigned, result->key);
+
             }
 
           /* free the remaining */
@@ -2387,13 +2382,12 @@ serialRegAssign (eBBlock ** ebbs, int count)
                  have been allocated after sym->liveFrom but freed
                  before ic->seq. This is complicated, so spill this
                  symbol instead and let fillGaps handle the allocation. */
-#if 0
               if (sym->liveFrom < ic->seq)
                 {
                     spillThis (sym);
                     continue;
                 }
-#endif
+
               /* if it has a spillocation & is used less than
                  all other live ranges then spill this */
                 if (willCS) {
@@ -4068,7 +4062,7 @@ pic16_packRegisters (eBBlock * ebp)
 #endif
 
     /* mark the pointer usages */
-    if (POINTER_SET (ic))
+    if (POINTER_SET (ic) && IS_SYMOP (IC_RESULT (ic)))
       {
         OP_SYMBOL (IC_RESULT (ic))->uptr = 1;
         debugLog ("  marking as a pointer (set) =>");