1) added some debug dumping
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 9 Sep 2000 19:13:48 +0000 (19:13 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 9 Sep 2000 19:13:48 +0000 (19:13 +0000)
2) Fixed Big BUG is register allocator (all ports fixed)

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

src/SDCCBBlock.c
src/SDCCmem.c
src/SDCCsymt.c
src/avr/ralloc.c
src/ds390/ralloc.c
src/mcs51/main.c
src/mcs51/ralloc.c
src/z80/ralloc.c

index 84c1ff56a126c93fafc5f5fc247570fc6624ea73..814944b9b0c9cd4485d43505e572ba0641addba6 100644 (file)
@@ -65,6 +65,70 @@ edge *newEdge (eBBlock *from, eBBlock *to)
     return ep;
 }
 
+/*-----------------------------------------------------------------*/
+/* dumpLiveRanges - dump liverange information into a file         */
+/*-----------------------------------------------------------------*/
+void dumpLiveRanges (char *ext,hTab *liveRanges)
+{
+    FILE *file;
+    symbol *sym;
+    int k;
+
+    if (ext) {
+       /* create the file name */
+       strcpy(buffer,srcFileName);
+       strcat(buffer,ext);
+       
+       if (!(file = fopen(buffer,"a+"))) {
+           werror(E_FILE_OPEN_ERR,buffer);
+           exit(1);
+       }
+    } else 
+       file = stdout;
+    
+    for (sym = hTabFirstItem(liveRanges,&k); sym ; 
+        sym = hTabNextItem(liveRanges,&k)) {
+
+       fprintf (file,"%s [k%d lr%d:%d so:%d]{ re%d rm%d}",
+                (sym->rname[0] ? sym->rname : sym->name), 
+                sym->key,
+                sym->liveFrom,sym->liveTo,
+                sym->stack,
+                sym->isreqv,sym->remat
+                );
+       
+       fprintf(file,"{"); printTypeChain(sym->type,file); 
+       if (sym->usl.spillLoc) {
+           fprintf(file,"}{ sir@ %s",sym->usl.spillLoc->rname);
+       }
+       fprintf(file,"}");
+       
+       /* if assigned to registers */
+       if (sym->nRegs) {
+           if (sym->isspilt) {
+               if (!sym->remat)
+                   if (sym->usl.spillLoc)
+                       fprintf(file,"[%s]",(sym->usl.spillLoc->rname[0] ?
+                                            sym->usl.spillLoc->rname :
+                                            sym->usl.spillLoc->name));
+                   else
+                       fprintf(file,"[err]");
+               else
+                   fprintf(file,"[remat]");
+           }
+           else {
+               int i;
+               fprintf(file,"[");
+               for(i=0;i<sym->nRegs;i++)
+                   fprintf(file,"%s ", port->getRegName(sym->regs[i]));
+               fprintf(file,"]");
+           }
+       }
+       fprintf(file,"\n");
+    }
+       
+    fclose(file);
+}
 /*-----------------------------------------------------------------*/
 /* dumpEbbsToFileExt - writeall the basic blocks to a file         */
 /*-----------------------------------------------------------------*/
@@ -73,14 +137,17 @@ void dumpEbbsToFileExt (char *ext,eBBlock **ebbs, int count)
     FILE *of;
     int i;
 
-    /* create the file name */
-    strcpy(buffer,srcFileName);
-    strcat(buffer,ext);
-
-    if (!(of = fopen(buffer,"a+"))) {
-       werror(E_FILE_OPEN_ERR,buffer);
-       exit(1);
-    }
+    if (ext) {
+       /* create the file name */
+       strcpy(buffer,srcFileName);
+       strcat(buffer,ext);
+       
+       if (!(of = fopen(buffer,"a+"))) {
+           werror(E_FILE_OPEN_ERR,buffer);
+           exit(1);
+       }
+    } else
+       of = stdout;
 
     for (i=0; i < count ; i++ ) {
        fprintf(of,"\n----------------------------------------------------------------\n");
index b3c8381f50cfae85bac5f6e1ad5e92e08ee72b86..616a3b7894fce9996ac708faa152b516d3ae5bff 100644 (file)
@@ -466,7 +466,7 @@ void allocParms ( value  *val )
                   first, we will remove it from the overlay segment
                   after the overlay determination has been done */
                SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = 
-                   ( options.model  ? port->mem.default_local_map : 
+                   ( options.model ? port->mem.default_local_map : 
                      (options.noOverlay ? port->mem.default_local_map
                       :overlay ));
            
@@ -534,7 +534,6 @@ void allocLocal ( symbol *sym  )
 
     /* if this is a static variable */
     if ( IS_STATIC (sym->etype)) {
-/*     SPEC_OCLS(sym->etype) = (options.model ? xdata : data ); */
        SPEC_OCLS(sym->etype) = port->mem.default_local_map;
        allocIntoSeg (sym);
         sym->allocreq = 1;
index 438863d78e330b89fbe8732628ba4a1e41d7db81..d7d64749e92861ed6d49c197589d8efacd645d8f 100644 (file)
@@ -1027,7 +1027,7 @@ static void  checkSClass ( symbol *sym )
            extern PORT ds390_port;
            bool useXdata = (port == &ds390_port) ? options.model : options.useXstack;
            SPEC_SCLS(sym->etype) = (useXdata  ?
-                                    S_XDATA : S_DATA ) ;
+                                    S_XDATA : S_FIXED ) ;
        }
     }
 }
index 728a05c5cef171a71f8a96d46da9f3fa9e1fdcb1..05e541a7ab0573a886dbcf2915fb2116e67254e0 100644 (file)
@@ -853,7 +853,7 @@ static void deassignLRs (iCode *ic, eBBlock *ebp)
                  sym->nRegs) >= result->nRegs)
                ) {
                
-               for (i = 0 ; i < max(sym->nRegs,result->nRegs) ; i++)
+               for (i = 0 ; i < result->nRegs ; i++)
                    if (i < sym->nRegs )
                        result->regs[i] = sym->regs[i] ;
                    else
index 1e6e8dc8c0eec1559f514c27ed5a2bc24dd36df6..ef208c28675f340f77716dda7fe1812ed3d23187 100644 (file)
@@ -870,7 +870,7 @@ static void deassignLRs (iCode *ic, eBBlock *ebp)
                  sym->nRegs) >= result->nRegs)
                ) {
                
-               for (i = 0 ; i < max(sym->nRegs,result->nRegs) ; i++)
+               for (i = 0 ; i < result->nRegs ; i++)
                    if (i < sym->nRegs )
                        result->regs[i] = sym->regs[i] ;
                    else
index 991fb055ac2790f9435bd5303c6866886e77ff3d..182788932c7c6bd50323e66cc6748e3ae7150737 100644 (file)
@@ -96,7 +96,7 @@ static void _mcs51_finaliseOptions(void)
         fReturnSize = 5;
     } 
 
-    if (options.model) {
+    if (options.model == MODEL_LARGE) {
        port->mem.default_local_map = xdata;
        port->mem.default_globl_map = xdata;
     } else {
index 368f58fa7ae72682b7ca981b9a5f0cecc514cf0d..15169afba42cda186aaec75152a0695fea6db8b4 100644 (file)
@@ -869,7 +869,7 @@ static void deassignLRs (iCode *ic, eBBlock *ebp)
                  sym->nRegs) >= result->nRegs)
                ) {
                
-               for (i = 0 ; i < max(sym->nRegs,result->nRegs) ; i++)
+               for (i = 0 ; i < result->nRegs ; i++)
                    if (i < sym->nRegs )
                        result->regs[i] = sym->regs[i] ;
                    else
@@ -2306,8 +2306,10 @@ void mcs51_assignRegisters (eBBlock **ebbs, int count)
     /* redo that offsets for stacked automatic variables */
     redoStackOffsets ();
 
-    if (options.dump_rassgn)
+    if (options.dump_rassgn) {
        dumpEbbsToFileExt(".dumprassgn",ebbs,count);
+       dumpLiveRanges(".lrange",liveRanges);
+    }
 
     /* now get back the chain */
     ic = iCodeLabelOptimize(iCodeFromeBBlock (ebbs,count));
index 75127f84b3fb7d8fec6f7284f892e5b0db1be527..9f42f5918c4c2e69dd3cb819abc8f3c0fb328d09 100644 (file)
@@ -789,7 +789,7 @@ static void deassignLRs (iCode *ic, eBBlock *ebp)
                ((nfreeRegsType(result->regType) +
                  sym->nRegs) >= result->nRegs)
                ) {
-               for (i = 0 ; i < max(sym->nRegs,result->nRegs) ; i++) {
+               for (i = 0 ; i < result->nRegs ; i++) {
                    if (i < sym->nRegs )
                        result->regs[i] = sym->regs[i] ;
                    else