* src/pic16/gen.c (genPackBits): added operand right in function
[fw/sdcc] / src / SDCCmem.c
index 40d422b12d38b430da755a18f82340f36930d57b..b2a8c7b5dfca427c88d4b93cb97839ee1f3e7356 100644 (file)
@@ -325,9 +325,9 @@ allocGlobal (symbol * sym)
       SPEC_OCLS (sym->etype) = code;
       /* if this is an interrupt service routine
          then put it in the interrupt service array */
-      if (FUNC_ISISR (sym->type) && !options.noiv)
+      if (FUNC_ISISR (sym->type) && !options.noiv
+          && (FUNC_INTNO (sym->type) != INTNO_UNSPEC))
        {
-
          if (interrupts[FUNC_INTNO (sym->type)])
            werror (E_INT_DEFINED,
                    FUNC_INTNO (sym->type),
@@ -375,6 +375,7 @@ allocGlobal (symbol * sym)
       return;
     }
 
+  if(!TARGET_IS_PIC16 || (TARGET_IS_PIC16 && sym->level))
   /* register storage class ignored changed to FIXED */
   if (SPEC_SCLS (sym->etype) == S_REGISTER)
     SPEC_SCLS (sym->etype) = S_FIXED;
@@ -392,6 +393,7 @@ allocGlobal (symbol * sym)
   /* if it is fixed, then allocate depending on the  */
   /* current memory model, same for automatics        */
   if (SPEC_SCLS (sym->etype) == S_FIXED ||
+      (TARGET_IS_PIC16 && (SPEC_SCLS (sym->etype) == S_REGISTER) && (sym->level==0)) ||
       SPEC_SCLS (sym->etype) == S_AUTO) {
     if (port->mem.default_globl_map != xdata) {
       /* set the output class */
@@ -563,8 +565,9 @@ deallocParms (value * val)
       if (!lval->sym->isref)
        {
          lval->sym->allocreq = 0;
-         werror (W_NO_REFERENCE, currFunc->name,
-                 "function argument", lval->sym->name);
+           werror (W_NO_REFERENCE, 
+                   currFunc ? currFunc->name : "(unknown)",
+                   "function argument", lval->sym->name);
        }
 
       /* move the rname if any to the name for both val & sym */
@@ -709,11 +712,11 @@ allocLocal (symbol * sym)
      will remove and put into the 'data' segment if required after 
      overlay  analysis has been done */
   if (options.model == MODEL_SMALL) {
-    SPEC_OCLS (sym->etype) = 
-      (options.noOverlay ? port->mem.default_local_map
-       : overlay);
+      SPEC_OCLS (sym->etype) = 
+       (options.noOverlay ? port->mem.default_local_map
+        : overlay);
   } else {
-    SPEC_OCLS (sym->etype) = port->mem.default_local_map;
+      SPEC_OCLS (sym->etype) = port->mem.default_local_map;
   }
   allocIntoSeg (sym);
 }
@@ -741,7 +744,8 @@ deallocLocal (symbol * csym)
        }
       /* if not used give a warning */
       if (!sym->isref && !IS_STATIC (sym->etype))
-       werror (W_NO_REFERENCE, currFunc->name,
+       werror (W_NO_REFERENCE, 
+               currFunc ? currFunc->name : "(unknown)",
                "local variable", sym->name);
       /* now delete it from the symbol table */
       deleteSym (SymbolTab, sym, sym->name);
@@ -764,7 +768,7 @@ overlay2data ()
       allocIntoSeg (sym);
     }
 
-  setToNull ((void **) &overlay->syms);
+  setToNull ((void *) &overlay->syms);
 
 }
 
@@ -785,7 +789,7 @@ overlay2Set ()
       addSet (&oset, sym);
     }
 
-  setToNull ((void **) &overlay->syms);
+  setToNull ((void *) &overlay->syms);
   addSet (&ovrSetSets, oset);
 
 }
@@ -814,6 +818,7 @@ allocVariables (symbol * symChain)
          if (csym && csym->level == sym->level)
            werror (E_DUPLICATE_TYPEDEF, sym->name);
 
+         SPEC_EXTR (sym->etype) = 0;
          addSym (TypedefTab, sym, sym->name, sym->level, sym->block, 0);
          continue;             /* go to the next one         */
        }
@@ -960,18 +965,6 @@ redoStackOffsets (void)
       xsPtr += size;
     }
 
-  /* if the debug option is set then output the
-     symbols to the map file */
-  if (options.debug)
-    {
-      for (sym = setFirstItem (istack->syms); sym;
-          sym = setNextItem (istack->syms))
-       cdbSymbol (sym, cdbFile, FALSE, FALSE);
-
-      for (sym = setFirstItem (xstack->syms); sym;
-          sym = setNextItem (xstack->syms))
-       cdbSymbol (sym, cdbFile, FALSE, FALSE);
-    }
 }
 
 /*-----------------------------------------------------------------*/
@@ -986,7 +979,7 @@ printAllocInfoSeg (memmap * map, symbol * func, FILE * of)
     return;
   if (!map->syms)
     return;
-
+  
   for (sym = setFirstItem (map->syms); sym;
        sym = setNextItem (map->syms))
     {
@@ -995,7 +988,8 @@ printAllocInfoSeg (memmap * map, symbol * func, FILE * of)
        continue;
       if (sym->localof != func)
        continue;
-      fprintf (of, ";%-25s Allocated to ", sym->name);
+      
+      fprintf (of, ";%-25s Allocated ", sym->name);
 
       /* if assigned to registers */
       if (!sym->allocreq && sym->reqv)
@@ -1003,22 +997,29 @@ printAllocInfoSeg (memmap * map, symbol * func, FILE * of)
          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 (!sym->isspilt || sym->remat)
+           {
+             fprintf (of, "to registers ");
+             for (i = 0; i < 4 && sym->regs[i]; i++)
+               fprintf (of, "%s ", port->getRegName (sym->regs[i]));
+             fprintf (of, "\n");
+             continue;
+           }
+         else
+           {
+             sym = sym->usl.spillLoc;
+           }
        }
 
       /* if on stack */
       if (sym->onStack)
        {
-         fprintf (of, "stack - offset %d\n", sym->stack);
+         fprintf (of, "to stack - offset %d\n", sym->stack);
          continue;
        }
 
       /* otherwise give rname */
-      fprintf (of, "in memory with name '%s'\n", sym->rname);
+      fprintf (of, "with name '%s'\n", sym->rname);
     }
 }
 
@@ -1095,6 +1096,9 @@ doOverlays (eBBlock ** ebbs, int count)
 void 
 printAllocInfo (symbol * func, FILE * of)
 {
+  if (!func)
+       return;
+    
   if (!of)
     of = stdout;
 
@@ -1111,5 +1115,20 @@ printAllocInfo (symbol * func, FILE * of)
   printAllocInfoSeg (idata, func, of);
   printAllocInfoSeg (sfr, func, of);
   printAllocInfoSeg (sfrbit, func, of);
+  
+  {
+    set *ovrset;
+    set *tempOverlaySyms = overlay->syms;
+    
+    /* search the set of overlay sets for local variables/parameters */
+    for (ovrset = setFirstItem (ovrSetSets); ovrset;
+         ovrset = setNextItem (ovrSetSets))
+      {
+        overlay->syms = ovrset;
+        printAllocInfoSeg (overlay, func, of);
+      }
+    overlay->syms = tempOverlaySyms;
+  }
+  
   fprintf (of, ";------------------------------------------------------------\n");
 }