options.model specific fixes
[fw/sdcc] / src / SDCCsymt.c
index 33585fddb57f580bbc1a9bee09354c91d9dd0614..c91eb6a6f4dfa77d6c65d3114f251d7d7b8e1697 100644 (file)
@@ -23,8 +23,6 @@
 
 #include "common.h"
 
-#define ENABLE_MICHAELH_REGPARM_HACK   0
-
 bucket   *SymbolTab [256]  ;  /* the symbol    table  */
 bucket   *StructTab [256]  ;  /* the structure table  */
 bucket   *TypedefTab[256]  ;  /* the typedef   table  */
@@ -60,7 +58,7 @@ bucket         *newBucket ()
 /*-----------------------------------------------------------------*/
 /* hashKey - computes the hashkey given a symbol name              */
 /*-----------------------------------------------------------------*/
-int hashKey (char *s)
+int hashKey (const char *s)
 {
     unsigned long key = 0;
 
@@ -144,7 +142,7 @@ void  deleteSym ( bucket **stab, void *sym, char *sname)
 /*-----------------------------------------------------------------*/
 /* findSym - finds a symbol in a table                            */
 /*-----------------------------------------------------------------*/
-void  *findSym ( bucket **stab, void *sym, char *sname)
+void  *findSym ( bucket **stab, void *sym, const char *sname)
 {
    bucket *bp ;
 
@@ -1016,11 +1014,21 @@ static void  checkSClass ( symbol *sym )
     /* the storage class to reflect where the var will go */
     if ( sym->level && SPEC_SCLS(sym->etype) == S_FIXED) {
        if ( options.stackAuto || (currFunc && IS_RENT(currFunc->etype)))
+       {
            SPEC_SCLS(sym->etype) = (options.useXstack  ?
                                     S_XSTACK : S_STACK ) ;
+       }
        else
-           SPEC_SCLS(sym->etype) = (options.useXstack  ?
-                                    S_XDATA :S_DATA ) ;
+       {
+           /* hack-o-matic! I see no reason why the useXstack option should ever
+            * control this allcoation, but the code was originally that way, and
+            * changing it for non-390 ports breaks the compiler badly.
+            */
+           extern PORT ds390_port;
+           bool useXdata = (port == &ds390_port) ? options.model : options.useXstack;
+           SPEC_SCLS(sym->etype) = (useXdata  ?
+                                    S_XDATA : S_FIXED ) ;
+       }
     }
 }
 
@@ -1415,24 +1423,10 @@ void  processFuncArgs   (symbol *func, int ignoreName)
           not inhibited by command line option or #pragma */
        if (!func->hasVargs       &&        
            !options.noregparms   &&
+           !IS_RENT(func->etype) &&
            (*port->reg_parm)(val->type)) {
-
            SPEC_REGPARM(val->etype) = 1;
        }
-
-#if ENABLE_MICHAELH_REGPARM_HACK
-       /* HACK: pull out later */
-       if (
-           (
-            !strcmp(func->name, "memcpy") ||
-            !strcmp(func->name, "strcpy") ||
-            !strcmp(func->name, "strcmp") ||
-            0
-            ) &&
-           port->reg_parm(val->type)) {
-           SPEC_REGPARM(val->etype) = 1;
-       }
-#endif                                         
        
        if ( IS_AGGREGATE(val->type)) {
            /* if this is a structure */
@@ -1501,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;
@@ -1836,7 +1830,8 @@ void cdbStructBlock (int block , FILE *of)
     int i ;
     bucket **table = StructTab;
     bucket  *chain;
-    
+    wassert(of);
+
     /* go thru the entire  table  */
     for ( i = 0 ; i < 256; i++ ) {
        for ( chain = table[i]; chain ; chain = chain->next ) {
@@ -1885,7 +1880,6 @@ symbol *__conv[2][3][2];
 
 link *floatType;
 
-#if ENABLE_MICHAELH_REGPARM_HACK
 static void _makeRegParam(symbol *sym)
 {
     value *val ;
@@ -1900,7 +1894,6 @@ static void _makeRegParam(symbol *sym)
        val = val->next ;
     }
 }
-#endif
 
 /*-----------------------------------------------------------------*/ 
 /* initCSupport - create functions for C support routines          */
@@ -1976,10 +1969,8 @@ void initCSupport ()
                        sbwd[bwd]);
                __muldiv[muldivmod][bwd][su] = funcOfType(buffer, __multypes[bwd][su], __multypes[bwd][su], 2, options.intlong_rent);
                SPEC_NONBANKED(__muldiv[muldivmod][bwd][su]->etype) = 1;
-#if ENABLE_MICHAELH_REGPARM_HACK
-               if (bwd < 2) 
+               if (bwd < port->muldiv.force_reg_param_below) 
                    _makeRegParam(__muldiv[muldivmod][bwd][su]);
-#endif
            }
        }
     }