This shows the registers in use in --i-code-in-asm and saves some spill locs
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 8 Apr 2003 12:51:35 +0000 (12:51 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 8 Apr 2003 12:51:35 +0000 (12:51 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2495 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCicode.h
src/mcs51/gen.c
src/mcs51/ralloc.c

index c11628ff90d46ffeda2157158f7d445cbe22401d..8c9ac33dea748e7fcc0d8828e722fb3ae4ee599e 100644 (file)
@@ -189,6 +189,7 @@ typedef struct iCode
                                   on stack */
     int argreg;                        /* argument regno for SEND/RECEIVE */
     int eBBlockNum;             /* belongs to which eBBlock */
+    char riu;                  /* after ralloc, the registers in use */
   }
 iCode;
 
index 6dcefa60726362697c362fda1e4766227cdf297d..9b28f9b4adbd710ec1ea58b666837711a86db3dd 100644 (file)
@@ -8919,7 +8919,15 @@ gen51Code (iCode * lic)
          cln = ic->lineno;
        }
       if (options.iCodeInAsm) {
-       emitcode("", ";ic:%d: %s", ic->key, printILine(ic));
+       char regsInUse[80];
+       int i;
+
+       for (i=0; i<8; i++) {
+         sprintf (&regsInUse[i],
+                  "%c", ic->riu & (1<<i) ? i+'0' : '-'); 
+       }
+       regsInUse[i]=0;
+       emitcode("", "; [%s] ic:%d: %s", regsInUse, ic->seq, printILine(ic));
       }
       /* if the result is marked as
          spilt and rematerializable or code for
index bf3d162f02809cf0c9259391842376c255433a01..a87aae9a6eaab78e8806457a08e068c939961164 100644 (file)
@@ -1107,6 +1107,16 @@ serialRegAssign (eBBlock ** ebbs, int count)
 
        /* of all instructions do */
        for (ic = ebbs[i]->sch; ic; ic = ic->next) {
+           int i;
+
+           // update the registers in use at the start of this icode
+           for (i=0; i<8; i++) {
+             if (regs8051[i].isFree) {
+               ic->riu &= ~(1<<regs8051[i].offset);
+             } else {
+               ic->riu |= (1<<regs8051[i].offset);
+             }
+           }
 
            /* if this is an ipop that means some live
               range will have to be assigned again */
@@ -2790,6 +2800,7 @@ mcs51_assignRegisters (eBBlock ** ebbs, int count)
   int i;
 
   setToNull ((void *) &_G.funcrUsed);
+  setToNull ((void *) &_G.regAssigned);
   setToNull ((void *) &_G.totRegAssigned);
   mcs51_ptrRegReq = _G.stackExtend = _G.dataExtend = 0;
   mcs51_nRegs = 8;
@@ -2810,6 +2821,8 @@ mcs51_assignRegisters (eBBlock ** ebbs, int count)
   serialRegAssign (ebbs, count);
 
   freeAllRegs ();
+  setToNull ((void *) &_G.regAssigned);
+  setToNull ((void *) &_G.totRegAssigned);
   fillGaps();
 
   /* if stack was extended then tell the user */