extern void pic16_AnalyzeBanking (void);
extern void pic16_OptimizeJumps ();
+extern void pic16_OptimizeBanksel ();
extern void copyFile (FILE * dest, FILE * src);
extern void pic16_InlinepCode(void);
extern void pic16_writeUsedRegs(FILE *);
checkAddSym(&publics, sym);
} else
+ /* new version */
if(IS_STATIC(sym->etype)
- && !(sym->ival && !sym->level)
- ) {
+ && !sym->ival) /* && !sym->level*/ {
regs *reg;
sectSym *ssym;
int found=0;
+
+// debugf("adding symbol %s\n", sym->name);
#define SET_IMPLICIT 1
#if SET_IMPLICIT
reg = pic16_allocDirReg( operandFromSymbol( sym ));
if(reg) {
-#if 1
for(ssym=setFirstItem(sectSyms); ssym; ssym=setNextItem(sectSyms)) {
if(!strcmp(ssym->name, reg->name))found=1;
}
-#endif
+
if(!found)
checkAddReg(&pic16_rel_udata, reg);
+#if 0
else
- checkAddSym(&publics, sym);
+ debugf("Did find %s in pic16_rel_udata already. Check!\n", reg->name);
+// checkAddSym(&publics, sym);
+#endif
}
}
continue;
}
-#if 0
- /* print extra debug info if required */
- if (options.debug || sym->level == 0) {
- cdbWriteSymbol (sym); //, cdbFile, FALSE, FALSE);
-
- if (!sym->level) /* global */
- if (IS_STATIC (sym->etype))
- fprintf (map->oFile, "F%s_", moduleName); /* scope is file */
- else
- fprintf (map->oFile, "G_"); /* scope is global */
- else
- /* symbol is local */
- fprintf (map->oFile, "L%s_", (sym->localof ? sym->localof->name : "-null-"));
- fprintf (map->oFile, "%s_%d_%d", sym->name, sym->level, sym->block);
- }
-#endif
-
-
/* if is has an absolute address then generate
an equate for this no need to allocate space */
if (SPEC_ABSA (sym->etype)) {
-// if (options.debug || sym->level == 0)
// fprintf (stderr,"; %s == 0x%04x\t\treqv= %p nRegs= %d\n",
// sym->name, SPEC_ADDR (sym->etype), sym->reqv, sym->regType);
/* if it has an initial value then do it only if
it is a global variable */
- if (sym->ival && sym->level == 0) {
+ if (sym->ival
+ && ((sym->level == 0)
+ || IS_STATIC(sym->etype)) ) {
ast *ival = NULL;
#if 0
fprintf (afile, "%s", iComments2);
for(sym = setFirstItem (publics); sym; sym = setNextItem (publics))
+ /* sanity check */
+ if(!IS_STATIC(sym->etype))
fprintf(afile, "\tglobal %s\n", sym->rname);
}
if (IS_FUNC (sym->type))
continue;
-#if 0
- /* print extra debug info if required */
- if (options.debug || sym->level == 0)
- {
-
- cdbSymbol (sym, cdbFile, FALSE, FALSE);
-
- if (!sym->level)
- { /* global */
- if (IS_STATIC (sym->etype))
- fprintf (afile, "F%s_", moduleName); /* scope is file */
- else
- fprintf (afile, "G_"); /* scope is global */
- }
- else
- /* symbol is local */
- fprintf (afile, "L%s_",
- (sym->localof ? sym->localof->name : "-null-"));
- fprintf (afile, "%s_%d_%d", sym->name, sym->level, sym->block);
- }
-#endif
/* if is has an absolute address then generate
an equate for this no need to allocate space */
void emitStatistics(FILE *asmFile)
{
+ unsigned long isize, udsize;
statistics.isize = pic16_countInstructions();
+ isize = (statistics.isize >= 0) ? statistics.isize : 0;
+ udsize = (statistics.udsize >= 0) ? statistics.udsize : 0;
fprintf (asmFile, "\n\n; Statistics:\n");
- fprintf (asmFile, "; code size:\t%ld (0x%lx) bytes\n;\t\t%ld (0x%lx) words\n",
- statistics.isize, statistics.isize,
- statistics.isize>>1, statistics.isize>>1);
- fprintf (asmFile, "; udata size:\t%ld (0x%lx) bytes\n",
- statistics.udsize, statistics.udsize);
- fprintf (asmFile, "; access size:\t%ld (0x%lx) bytes\n",
+ fprintf (asmFile, "; code size:\t%5ld (0x%04lx) bytes (%3.2f%%)\n; \t%5ld (0x%04lx) words\n",
+ isize, isize, (isize*100.0)/(128 << 10),
+ isize>>1, isize>>1);
+ fprintf (asmFile, "; udata size:\t%5ld (0x%04lx) bytes (%3.2f%%)\n",
+ udsize, udsize, (udsize*100.0) / ((pic16 ? pic16->RAMsize : 0x200) -256));
+ fprintf (asmFile, "; access size:\t%5ld (0x%04lx) bytes\n",
statistics.intsize, statistics.intsize);
fprintf (asmFile, "\n\n");
pic16_OptimizeLocalRegs();
}
+ /* remove redundant BANKSELs -- added by RN 2005-01-17 */
+ if(pic16_options.opt_banksel > 1) {
+ pic16_OptimizeBanksel();
+ }
+
/* turn GOTOs into BRAs -- added by RN 2004-11-16 */
if(pic16_options.opt_flags & OF_OPTIMIZE_GOTO) {
pic16_OptimizeJumps();