options.model specific fixes
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 10 Sep 2000 02:13:23 +0000 (02:13 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 10 Sep 2000 02:13:23 +0000 (02:13 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@349 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCBBlock.h
src/SDCCdflow.c
src/SDCCmem.c
src/SDCCmem.h
src/SDCCopt.c
src/SDCCsymt.c

index 51d53726f0519172e588782f9fe646f1086d19fd..b12a5e397c194026c0fa3de83d3e2fe7766c7092 100644 (file)
@@ -27,7 +27,7 @@
 #define SDCCBBLOCK_H 1
 
 /* definition of a basic block */
-typedef struct eBasicBlock {
+typedef struct eBBlock {
     int dfnum ;             /* depth first number */
     int bbnum ;             /* index into array of numbers */
     int depth ;             /* loop depth of this block */
@@ -42,7 +42,7 @@ typedef struct eBasicBlock {
     iCode *sch ;            /* pointer to start of code chain */
     iCode *ech ;            /* pointer to last of code chain  */
 
-    struct eBasicBlock *preHeader ; /* preheader if this is a loop entry */
+    struct eBBlock     *preHeader ; /* preheader if this is a loop entry */
     struct region      *partOfLoop; /* pointer to the loop region this block is part of */
 
     /* control flow analysis */
index 971ed998fa12e8694c66c55b2d8c95d040f1d21a..76c2267a77b20d8dd4c1b4fccbc252d01d377de9 100644 (file)
@@ -182,10 +182,9 @@ void computeDataFlow (eBBlock **ebbs, int count)
            /* indefitions are easy just merge them by union */
            /* these are the definitions that can possibly   */
            /* reach this block                              */
-           firstTime = 1;          
+           firstTime = 1;
            applyToSet(pred,mergeInDefs,ebbs[i],&firstTime);
 
-
            /* if none of the edges coming to this block */
            /* dominate this block then add the immediate dominator */
            /* of this block to the list of predecessors */
@@ -205,9 +204,10 @@ void computeDataFlow (eBBlock **ebbs, int count)
            /* figure out the incoming expressions */
            /* this is a little more complex       */       
            setToNull ((void **)&ebbs[i]->inExprs);
-           firstTime = 1;
-           applyToSet(pred,mergeInExprs,ebbs[i],&firstTime); 
-
+           if (optimize.global_cse) {
+                   firstTime = 1;
+                   applyToSet(pred,mergeInExprs,ebbs[i],&firstTime); 
+           }
            setToNull ((void **)&pred);
            
            /* do cse with computeOnly flag set to TRUE */
index 616a3b7894fce9996ac708faa152b516d3ae5bff..2fb79e0b992642998610d07f1a6bd05da71ab147 100644 (file)
@@ -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 == MODEL_SMALL ? port->mem.default_local_map : 
                      (options.noOverlay ? port->mem.default_local_map
                       :overlay ));
            
@@ -640,7 +640,7 @@ void allocLocal ( symbol *sym  )
     /* again note that we have put it into the overlay segment
        will remove and put into the 'data' segment if required after 
        overlay  analysis has been done */   
-    SPEC_OCLS(sym->etype) = ( options.model  ? port->mem.default_local_map : 
+    SPEC_OCLS(sym->etype) = ( options.model == MODEL_SMALL ? port->mem.default_local_map : 
                              (options.noOverlay ? port->mem.default_local_map
                               : overlay )) ;
     allocIntoSeg (sym); 
@@ -914,6 +914,58 @@ static void printAllocInfoSeg ( memmap *map, symbol *func, FILE *of)
     }
 }
 
+/*-----------------------------------------------------------------*/
+/* canOverlayLocals - returns true if the local variables can overlayed */
+/*-----------------------------------------------------------------*/
+static bool canOverlayLocals (eBBlock **ebbs, int count)
+{
+    int i;
+    /* if staticAuto is in effect or the current function
+       being compiled is reentrant or the overlay segment
+       is empty or no overlay option is in effect then */
+    if (options.noOverlay ||
+       options.stackAuto ||
+       (currFunc &&
+        (IS_RENT(currFunc->etype) ||
+         IS_ISR(currFunc->etype))) ||
+       elementsInSet(overlay->syms) == 0)
+       
+       return FALSE;
+
+    /* otherwise do thru the blocks and see if there
+       any function calls if found then return false */
+    for (i = 0; i < count ; i++ ) {
+       iCode *ic;
+
+       for (ic = ebbs[i]->sch; ic ; ic = ic->next)
+           if (ic && ( ic->op == CALL || ic->op == PCALL))
+               return FALSE;
+    }
+
+    /* no function calls found return TRUE */
+    return TRUE;
+}
+
+/*-----------------------------------------------------------------*/
+/* doOverlays - move the overlay segment to appropriate location   */
+/*-----------------------------------------------------------------*/
+void doOverlays( eBBlock **ebbs, int count)
+{
+    /* check if the parameters and local variables
+       of this function can be put in the overlay segment
+       This check is essentially to see if the function
+       calls any other functions if yes then we cannot
+       overlay */
+    if (canOverlayLocals(ebbs,count))
+       /* if we can then put the parameters &
+          local variables in the overlay set */
+       overlay2Set();       
+    else
+       /* otherwise put them into data where
+          they belong */
+       overlay2data();
+}
+
 /*-----------------------------------------------------------------*/
 /* printAllocInfo - prints allocation information for a function   */
 /*-----------------------------------------------------------------*/
index 7a1009d10c5ddab5573b00c716d404e594b58cfb..1f4a54dcb190d40786946452262fd820e30b7128 100644 (file)
@@ -7,6 +7,8 @@
 
 struct set ;
 struct value ;
+struct eBBlock;
+
 typedef  struct memmap{
     unsigned char  pageno;    /* page no for this variable  */
     const char     *sname;    /*   character prefix for map */
@@ -82,5 +84,6 @@ int         allocVariables (struct symbol  *                );
 void        overlay2Set    (                                );
 void        overlay2data   (                                );
 void        redoStackOffsets(                               );
-void        printAllocInfo (struct symbol *, FILE *);
+void        printAllocInfo (struct symbol *, FILE *         );
+void        doOverlays     (struct eBBlock **, int count    );
 #endif
index 3e1ff6fb2efc54182e2ebd10fa63fde3e77713eb..5e5afb9a15250529d7a396e2ac7ae66ebf53ce4f 100644 (file)
@@ -613,38 +613,6 @@ static void printCyclomatic (eBBlock **ebbs, int count)
     werror(I_CYCLOMATIC,currFunc->name,nEdges,nNodes, nEdges - nNodes + 2);
 }
 
-/*-----------------------------------------------------------------*/
-/* canOverlayLocals - returns true if the local variables can overlayed */
-/*-----------------------------------------------------------------*/
-static bool canOverlayLocals (eBBlock **ebbs, int count)
-{
-    int i;
-    /* if staticAuto is in effect or the current function
-       being compiled is reentrant or the overlay segment
-       is empty or no overlay option is in effect then */
-    if (options.noOverlay ||
-       options.stackAuto ||
-       (currFunc &&
-        (IS_RENT(currFunc->etype) ||
-         IS_ISR(currFunc->etype))) ||
-       elementsInSet(overlay->syms) == 0)
-       
-       return FALSE;
-
-    /* otherwise do thru the blocks and see if there
-       any function calls if found then return false */
-    for (i = 0; i < count ; i++ ) {
-       iCode *ic;
-
-       for (ic = ebbs[i]->sch; ic ; ic = ic->next)
-           if (ic && ( ic->op == CALL || ic->op == PCALL))
-               return FALSE;
-    }
-
-    /* no function calls found return TRUE */
-    return TRUE;
-}
-
 
 /*-----------------------------------------------------------------*/
 /* eBBlockFromiCode - creates extended basic blocks from iCode     */
@@ -767,19 +735,6 @@ eBBlock **eBBlockFromiCode (iCode *ic)
        operations to be as they are for optimzations */
     convertToFcall (ebbs,count);
 
-    /* check if the parameters and local variables
-       of this function can be put in the overlay segment
-       This check is essentially to see if the function
-       calls any other functions if yes then we cannot
-       overlay */
-    if (canOverlayLocals(ebbs,count))
-       /* if we can then put the parameters &
-          local variables in the overlay set */
-       overlay2Set();       
-    else
-       /* otherwise put them into data where
-          they belong */
-       overlay2data();
 
     /* compute the live ranges */
     computeLiveRanges (ebbs,count);
@@ -797,4 +752,6 @@ eBBlock **eBBlockFromiCode (iCode *ic)
 
     return NULL;
 }
+
+
 /* (add-hook 'c-mode-hook (lambda () (setq c-basic-offset 4))) */
index d7d64749e92861ed6d49c197589d8efacd645d8f..c91eb6a6f4dfa77d6c65d3114f251d7d7b8e1697 100644 (file)
@@ -1495,7 +1495,7 @@ void  processFuncArgs   (symbol *func, int ignoreName)
 
            sprintf(val->name,"_%s_PARM_%d",func->name,pNum++);
            val->sym = newSymbol(val->name,1);
-           SPEC_OCLS(val->etype) = (options.model ? xdata : data);
+           SPEC_OCLS(val->etype) = port->mem.default_local_map;
            val->sym->type = copyLinkChain (val->type);
            val->sym->etype = getSpec (val->sym->type);
            val->sym->_isparm = 1;