cleanup; moved extern's from .c to .h files for double check
[fw/sdcc] / src / SDCCsymt.c
index a6b711b8efbe0af35f105fb647699be75294a676..0bd3032f6bf786d6f7c6c96f36186bd3b6f9c719 100644 (file)
@@ -29,8 +29,6 @@ bucket   *TypedefTab[256]  ;  /* the typedef   table  */
 bucket   *LabelTab  [256]  ;  /* the Label     table  */
 bucket   *enumTab   [256]  ;  /* enumerated    table  */
 
-extern   struct set *publics;
-
 /*------------------------------------------------------------------*/
 /* initSymt () - initialises symbol table related stuff             */
 /*------------------------------------------------------------------*/
@@ -58,7 +56,7 @@ bucket         *newBucket ()
 /*-----------------------------------------------------------------*/
 /* hashKey - computes the hashkey given a symbol name              */
 /*-----------------------------------------------------------------*/
-int hashKey (char *s)
+int hashKey (const char *s)
 {
     unsigned long key = 0;
 
@@ -142,7 +140,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 ;
 
@@ -418,6 +416,7 @@ link  *mergeSpec ( link *dest, link *src )
     SPEC_BLEN(dest) |= SPEC_BLEN(src);
     SPEC_BSTR(dest) |= SPEC_BSTR(src);
     SPEC_TYPEDEF(dest) |= SPEC_TYPEDEF(src);
+    SPEC_NONBANKED(dest) |= SPEC_NONBANKED(src);
 
     if ( IS_STRUCT(dest) && SPEC_STRUCT(dest) == NULL )
        SPEC_STRUCT(dest) = SPEC_STRUCT(src);   
@@ -1013,11 +1012,20 @@ 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.
+            */
+           bool useXdata = IS_DS390_PORT ? options.model : options.useXstack;
+           SPEC_SCLS(sym->etype) = (useXdata  ?
+                                    S_XDATA : S_FIXED ) ;
+       }
     }
 }
 
@@ -1369,8 +1377,9 @@ int   checkFunction (symbol   *sym)
     deleteSym (SymbolTab,csym,csym->name);
     addSym    (SymbolTab,sym,sym->name,sym->level,sym->block);
     if (IS_EXTERN(csym->etype) && !
-       IS_EXTERN(sym->etype))
+       IS_EXTERN(sym->etype)) {
        addSet(&publics,sym);
+    }
     return 1 ;      
 }
 
@@ -1405,15 +1414,14 @@ void  processFuncArgs   (symbol *func, int ignoreName)
     /* if any of the arguments is an aggregate */
     /* change it to pointer to the same type */
     while (val) {
-
        /* mark it as a register parameter if
           the function does not have VA_ARG
           and as port dictates
           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;
        }
        
@@ -1484,7 +1492,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;
@@ -1819,7 +1827,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 ) {
@@ -1868,6 +1877,21 @@ symbol *__conv[2][3][2];
 
 link *floatType;
 
+static void _makeRegParam(symbol *sym)
+{
+    value *val ;
+
+    val = sym->args; /* loop thru all the arguments   */
+
+    /* reset regparm for the port */
+    (*port->reset_regparms)();
+    while (val) {
+       SPEC_REGPARM(val->etype) = 1;
+       sym->argStack -= getSize(val->type);
+       val = val->next ;
+    }
+}
+
 /*-----------------------------------------------------------------*/ 
 /* initCSupport - create functions for C support routines          */
 /*-----------------------------------------------------------------*/ 
@@ -1941,6 +1965,9 @@ void initCSupport ()
                        ssu[su],
                        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 (bwd < port->muldiv.force_reg_param_below) 
+                   _makeRegParam(__muldiv[muldivmod][bwd][su]);
            }
        }
     }