* support/valdiag/valdiag.py: added -DPORT_HOST=1
[fw/sdcc] / src / SDCCmem.c
index ddf5ce66bb7e202d10356bfb47f01cf28402a2ac..ed4c4204022e0e0a80d23b16f72914202f87b4c7 100644 (file)
@@ -296,6 +296,8 @@ allocIntoSeg (symbol * sym)
 {
   memmap *segment = SPEC_OCLS (sym->etype);
   addSet (&segment->syms, sym);
+  if (segment == pdata)
+    sym->iaccess = 1;
 }
 
 /*-----------------------------------------------------------------*/
@@ -416,10 +418,10 @@ allocGlobal (symbol * sym)
     }
 
   /* if this is a bit variable and no storage class */
-  if (SPEC_NOUN (sym->etype) == V_BIT
-      /*&& SPEC_SCLS (sym->etype) == S_BIT*/)
+  if (IS_SPEC(sym->type) && SPEC_NOUN (sym->type) == V_BIT)
+      /*&& SPEC_SCLS (sym->etype) == S_BIT*/
     {
-      SPEC_OCLS (sym->etype) = bit;
+      SPEC_OCLS (sym->type) = bit;
       allocIntoSeg (sym);
       return;
     }
@@ -460,7 +462,6 @@ allocParms (value * val)
 
   for (lval = val; lval; lval = lval->next, pNum++)
     {
-
       /* check the declaration */
       checkDecl (lval->sym, 0);
 
@@ -474,11 +475,9 @@ allocParms (value * val)
       lval->sym->ismyparm = 1;
       lval->sym->localof = currFunc;
 
-
       /* if automatic variables r 2b stacked */
       if (options.stackAuto || IFFUNC_ISREENT (currFunc->type))
         {
-
           if (lval->sym)
             lval->sym->onStack = 1;
 
@@ -531,25 +530,31 @@ allocParms (value * val)
               continue;
             }
 
-            /* otherwise depending on the memory model
-               note here that we put it into the overlay segment
-               first, we will remove it from the overlay segment
-               after the overlay determination has been done */
-            if (options.model == MODEL_SMALL)
-              {
-                SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
-                  (options.noOverlay ? port->mem.default_local_map
-                   : overlay);
-              }
-            else
-              {
-                SPEC_SCLS (lval->etype) = S_XDATA;
-                SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = xdata;
-              }
+          /* otherwise depending on the memory model */
+          SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
+              port->mem.default_local_map;
+          if (options.model == MODEL_SMALL)
+            {
+              /* note here that we put it into the overlay segment
+                 first, we will remove it from the overlay segment
+                 after the overlay determination has been done */
+              if (!options.noOverlay)
+                {
+                  SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
+                    overlay;
+                }
+            }
+          else if (options.model == MODEL_MEDIUM)
+            {
+              SPEC_SCLS (lval->etype) = S_PDATA;
+            }
+          else
+            {
+              SPEC_SCLS (lval->etype) = S_XDATA;
+            }
           allocIntoSeg (lval->sym);
         }
     }
-
   return;
 }
 
@@ -563,7 +568,6 @@ deallocParms (value * val)
 
   for (lval = val; lval; lval = lval->next)
     {
-
       /* unmark is myparm */
       lval->sym->ismyparm = 0;
 
@@ -591,13 +595,12 @@ deallocParms (value * val)
           addSym (SymbolTab, lval->sym, lval->sym->name,
                   lval->sym->level, lval->sym->block, 1);
           lval->sym->_isparm = 1;
-          if (!isinSet (operKeyReset, lval->sym)) {
-            addSet(&operKeyReset, lval->sym);
-          }
+          if (!isinSet (operKeyReset, lval->sym))
+            {
+              addSet(&operKeyReset, lval->sym);
+            }
         }
-
     }
-
   return;
 }
 
@@ -607,7 +610,6 @@ deallocParms (value * val)
 void
 allocLocal (symbol * sym)
 {
-
   /* generate an unique name */
   SNPRINTF (sym->rname, sizeof(sym->rname),
             "%s%s_%s_%d_%d",
@@ -663,15 +665,15 @@ allocLocal (symbol * sym)
     }
 
   /* if this is a bit variable and no storage class */
-  if (SPEC_NOUN (sym->etype) == V_BIT)
+  if (IS_SPEC(sym->type) && SPEC_NOUN (sym->type) == V_BIT)
     {
-      SPEC_SCLS (sym->etype) = S_BIT;
-      SPEC_OCLS (sym->etype) = bit;
+      SPEC_SCLS (sym->type) = S_BIT;
+      SPEC_OCLS (sym->type) = bit;
       allocIntoSeg (sym);
       return;
     }
 
-  if (SPEC_SCLS (sym->etype) == S_DATA)
+  if ((SPEC_SCLS (sym->etype) == S_DATA) || (SPEC_SCLS (sym->etype) == S_REGISTER))
     {
       SPEC_OCLS (sym->etype) = (options.noOverlay ? data : overlay);
       allocIntoSeg (sym);
@@ -688,8 +690,7 @@ allocLocal (symbol * sym)
      overlay  analysis has been done */
   if (options.model == MODEL_SMALL) {
       SPEC_OCLS (sym->etype) =
-        (options.noOverlay ? port->mem.default_local_map
-         : overlay);
+        (options.noOverlay ? port->mem.default_local_map : overlay);
   } else {
       SPEC_OCLS (sym->etype) = port->mem.default_local_map;
   }