]> git.gag.com Git - fw/sdcc/commitdiff
Added print Allocation info will print
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 7 May 2000 22:41:27 +0000 (22:41 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 7 May 2000 22:41:27 +0000 (22:41 +0000)
the allocation information for function

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

src/SDCCglue.c
src/SDCCmem.c
src/SDCCmem.h
src/avr/main.c
src/mcs51/gen.c
src/mcs51/main.c
src/port.h
src/z80/main.c

index 4920cd18d98aea3fe4e9a5f2c4d0997e76e7d8c8..31ebf5b94868cae645376ba620bd58a5bf646995 100644 (file)
@@ -35,6 +35,7 @@ set *externs = NULL;          /* Varibles that are declared as extern */
 
 /* TODO: this should be configurable (DS803C90 uses more than 6) */
 int maxInterrupts = 6;
+int allocInfo = 1;
 extern int maxRegBank ;
 symbol *mainf;
 extern char *VersionString;
@@ -228,7 +229,9 @@ static void emitRegularMap (memmap * map, bool addPublics, bool arFlag)
                ival = newNode ('=', newAst (EX_VALUE, symbolVal (sym)),
                                decorateType (resolveSymbols (list2expr (sym->ival))));
            codeOutFile = statsg->oFile;
+           allocInfo = 0;
            eBBlockFromiCode (iCodeFromAst (ival));
+           allocInfo = 1;
            sym->ival = NULL;
        }
     }
@@ -1048,7 +1051,8 @@ void glue ()
     
     /* print the global variables in this module */
     printPublics (asmFile);
-    printExterns (asmFile);
+    if (port->assembler.externGlobal)
+       printExterns (asmFile);
 
     /* copy the sfr segment */
     fprintf (asmFile, "%s", iComments2);
index a134a4d9b9095898e79f55a602a01a214aa0f942..3ad2d92df4f7b834dab6af7587681367c676db09 100644 (file)
@@ -858,3 +858,64 @@ void redoStackOffsets ()
            cdbSymbol(sym,cdbFile,FALSE,FALSE); 
     }
 }
+
+/*-----------------------------------------------------------------*/
+/* printAllocInfoSeg- print the allocation for a given section     */
+/*-----------------------------------------------------------------*/
+static void printAllocInfoSeg ( memmap *map, symbol *func, FILE *of)
+{
+    symbol *sym;
+    
+    if (!map) return;
+    if (!map->syms) return;
+
+    for (sym = setFirstItem(map->syms); sym;
+        sym = setNextItem(map->syms)) {
+       
+       if (sym->level == 0) continue;
+       if (sym->localof != func) continue ;
+       fprintf(of,";%-25s Allocated to ",sym->name);
+
+       /* if assigned to registers */
+       if (!sym->allocreq && sym->reqv) {
+           int i;
+           sym = OP_SYMBOL(sym->reqv);
+           fprintf(of,"registers ");
+           for (i = 0 ; i < 4 && sym->regs[i] ; i++)
+               fprintf(of,"%s ",port->getRegName(sym->regs[i]));
+           fprintf(of,"\n");
+           continue ;
+       }
+
+       /* if on stack */
+       if (sym->onStack) {
+           fprintf(of,"stack - offset %d\n",sym->stack);
+           continue;
+       }
+       
+       /* otherwise give rname */
+       fprintf(of,"in memory with name '%s'\n",sym->rname);
+    }
+}
+
+/*-----------------------------------------------------------------*/
+/* printAllocInfo - prints allocation information for a function   */
+/*-----------------------------------------------------------------*/
+void printAllocInfo( symbol * func, FILE *of)
+{
+    if (!of) of = stdout;
+
+    /* must be called after register allocation is complete */
+    fprintf(of,";------------------------------------------------------------\n");
+    fprintf(of,";Allocation info for local variables in function '%s'\n",func->name);
+    fprintf(of,";------------------------------------------------------------\n");
+    
+    printAllocInfoSeg(xstack,func,of);
+    printAllocInfoSeg(istack,func,of);
+    printAllocInfoSeg(code,func,of);
+    printAllocInfoSeg(data,func,of);
+    printAllocInfoSeg(xdata,func,of);
+    printAllocInfoSeg(idata,func,of);
+    printAllocInfoSeg(sfr,func,of);
+    printAllocInfoSeg(sfrbit,func,of);
+}
index 54f5229ad4dad1c11105f8883bff681d1ceac589..b52eb9a332ab20d400818206d7c26671834c8d56 100644 (file)
@@ -79,5 +79,5 @@ int         allocVariables (struct symbol  *                );
 void        overlay2Set    (                                );
 void        overlay2data   (                                );
 void        redoStackOffsets(                               );
-
+void        printAllocInfo (struct symbol *, FILE *);
 #endif
index dd194986be6f34a46c221dcb3c25ae2cb6a60cde..c0f05c38ea8d6e4d58580988f5f7626372316c78 100644 (file)
@@ -145,6 +145,7 @@ PORT avr_port = {
        _asmCmd,
        "-plosgffc",            /* Options with debug */
        "-plosgff",             /* Options without debug */
+       0
     },
     {
        _linkCmd
index 1b99d94be5a6f52c197086d45ded8b1bae94108b..602ffba0590ac43bb93e5223d12f3a00f5b36e63 100644 (file)
@@ -53,6 +53,7 @@
 #include "gen.h"
 
 char *aopLiteral (value *val, int offset);
+extern int allocInfo;
 
 /* this is the down and dirty file with all kinds of 
    kludgy & hacky stuff. This is what it is all about
@@ -7421,6 +7422,9 @@ void gen51Code (iCode *lic)
 
     lineHead = lineCurr = NULL;
 
+    /* print the allocation information */
+    if (allocInfo)
+       printAllocInfo( currFunc, codeOutFile);
     /* if debug information required */
 /*     if (options.debug && currFunc) { */
     if (currFunc) {
@@ -7656,6 +7660,6 @@ void gen51Code (iCode *lic)
        peepHole (&lineHead);
 
     /* now do the actual printing */
-    printLine (lineHead,codeOutFile);
+    printLine (lineHead,codeOutFile);    
     return;
 }
index e480975e3c763058407a4f727e8c66470d6b2630..2a2b8fc085153c1c135e5827778ccf1d45ec2cc6 100644 (file)
@@ -202,6 +202,7 @@ PORT mcs51_port = {
        _asmCmd,
        "-plosgffc",            /* Options with debug */
        "-plosgff",             /* Options without debug */
+       0
     },
     {
        _linkCmd
index fb2bc1b765cc551c8b44b44807a85739d4305b08..081e26db06f2010008fe04ea183d191d709c95ec 100644 (file)
@@ -30,6 +30,8 @@ typedef struct {
        const char *debug_opts;
        /** Arguments for normal assembly mode.  PENDING: ignored */
        const char *plain_opts;
+       /* print externs as global */
+       int externGlobal;
     } assembler;
 
     /* linker related info */
index b5d1849d2ed87f30f65eed22ead845a6c521968c..c46ce7c8781b80b304b41a933cad25b04753b431 100644 (file)
@@ -260,6 +260,7 @@ PORT gbz80_port = {
        _gbz80_asmCmd,
        "-plosgff",             /* Options with debug */
        "-plosgff",             /* Options without debug */
+       1
     },
     {
        _gbz80_linkCmd