From: sandeep Date: Sat, 9 Sep 2000 19:13:48 +0000 (+0000) Subject: 1) added some debug dumping X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=6740ca478d08cb1453265ba5a066ffbb4d13768f;p=fw%2Fsdcc 1) added some debug dumping 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 --- diff --git a/src/SDCCBBlock.c b/src/SDCCBBlock.c index 84c1ff56..814944b9 100644 --- a/src/SDCCBBlock.c +++ b/src/SDCCBBlock.c @@ -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;inRegs;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"); diff --git a/src/SDCCmem.c b/src/SDCCmem.c index b3c8381f..616a3b78 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -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; diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 438863d7..d7d64749 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -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 ) ; } } } diff --git a/src/avr/ralloc.c b/src/avr/ralloc.c index 728a05c5..05e541a7 100644 --- a/src/avr/ralloc.c +++ b/src/avr/ralloc.c @@ -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 diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 1e6e8dc8..ef208c28 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -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 diff --git a/src/mcs51/main.c b/src/mcs51/main.c index 991fb055..18278893 100644 --- a/src/mcs51/main.c +++ b/src/mcs51/main.c @@ -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 { diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index 368f58fa..15169afb 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -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)); diff --git a/src/z80/ralloc.c b/src/z80/ralloc.c index 75127f84..9f42f591 100644 --- a/src/z80/ralloc.c +++ b/src/z80/ralloc.c @@ -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