X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCsymt.c;h=02fad1ff6f0940058bf71e62b7c4c5b672624ee2;hb=f43be8b5c132bcd1a1b4783840d7e292cfec0370;hp=688e896685e4ea842a4cb18093000aa0ca616cd0;hpb=d935ec1dfcf761b5f0790fce80953d7b80d99252;p=fw%2Fsdcc diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 688e8966..02fad1ff 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -23,6 +23,8 @@ #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 */ @@ -293,11 +295,11 @@ void pointerTypes (link *ptr, link *type) DCL_TYPE(ptr) = POINTER ; break; case S_CODE: - DCL_PTR_CONST(ptr) = 1; + DCL_PTR_CONST(ptr) = port->mem.code_ro; DCL_TYPE(ptr) = CPOINTER ; break; - case S_FLASH: - DCL_TYPE(ptr) = FLPOINTER; + case S_EEPROM: + DCL_TYPE(ptr) = EEPPOINTER; break; default: DCL_TYPE(ptr) = GPOINTER; @@ -418,6 +420,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); @@ -565,7 +568,7 @@ unsigned int getSize ( link *p ) case PPOINTER: case POINTER: return ( PTRSIZE ) ; - case FLPOINTER: + case EEPPOINTER: case FPOINTER: case CPOINTER: return ( FPTRSIZE ); @@ -620,7 +623,7 @@ unsigned int bitsForType ( link *p ) case PPOINTER: case POINTER: return ( PTRSIZE * 8) ; - case FLPOINTER: + case EEPPOINTER: case FPOINTER: case CPOINTER: return ( FPTRSIZE * 8); @@ -930,13 +933,15 @@ static void checkSClass ( symbol *sym ) /* global variables declared const put into code */ if (sym->level == 0 && - SPEC_SCLS(sym->etype) == S_CONSTANT) + SPEC_SCLS(sym->etype) == S_CONSTANT) { SPEC_SCLS(sym->etype) = S_CODE ; - + SPEC_CONST(sym->etype) = 1; + } /* global variable in code space is a constant */ if (sym->level == 0 && - SPEC_SCLS(sym->etype) == S_CODE) + SPEC_SCLS(sym->etype) == S_CODE && + port->mem.code_ro ) SPEC_CONST(sym->etype) = 1; @@ -1003,6 +1008,7 @@ static void checkSClass ( symbol *sym ) if (SPEC_SCLS(sym->etype) == S_CODE && sym->ival == NULL && !sym->level && + port->mem.code_ro && !IS_EXTERN(sym->etype)) werror(E_CODE_NO_INIT,sym->name); @@ -1013,8 +1019,8 @@ static void checkSClass ( symbol *sym ) SPEC_SCLS(sym->etype) = (options.useXstack ? S_XSTACK : S_STACK ) ; else - SPEC_SCLS(sym->etype) = (options.useXstack ? - S_XDATA :S_DATA ) ; + SPEC_SCLS(sym->etype) = (options.model ? + S_XDATA : S_DATA ) ; } } @@ -1366,8 +1372,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 ; } @@ -1379,6 +1386,7 @@ void processFuncArgs (symbol *func, int ignoreName) value *val ; int pNum = 1; + /* if this function has variable argument list */ /* then make the function a reentrant one */ if (func->hasVargs) @@ -1395,19 +1403,36 @@ void processFuncArgs (symbol *func, int ignoreName) func->args = NULL ; return ; } - + + /* reset regparm for the port */ + (*port->reset_regparms)(); /* 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 nit have VA_ARG - and MAX_REG_PARMS not exceeded && + the function does not have VA_ARG + and as port dictates not inhibited by command line option or #pragma */ - if (pNum <= MAX_REG_PARMS && + if (!func->hasVargs && !options.noregparms && - !func->hasVargs) + (*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 */ @@ -1442,8 +1467,8 @@ void processFuncArgs (symbol *func, int ignoreName) case S_XDATA: DCL_TYPE(val->type) = FPOINTER; break; - case S_FLASH: - DCL_TYPE(val->type) = FLPOINTER; + case S_EEPROM: + DCL_TYPE(val->type) = EEPPOINTER; break; default : DCL_TYPE(val->type) = GPOINTER; @@ -1554,8 +1579,8 @@ void printTypeChain (link *type, FILE *of) if (DCL_PTR_CONST(type)) fprintf(of,"const "); break; - case FLPOINTER: - fprintf (of,"_flash * "); + case EEPPOINTER: + fprintf (of,"_eeprom * "); if (DCL_PTR_CONST(type)) fprintf(of,"const "); break; @@ -1625,6 +1650,9 @@ void printTypeChain (link *type, FILE *of) case V_BIT: fprintf(of,"bit {%d,%d}",SPEC_BSTR(type),SPEC_BLEN(type)); break; + + default: + break; } } type = type->next; @@ -1663,12 +1691,14 @@ void cdbTypeInfo (link *type,FILE *of) case PPOINTER: fprintf (of,"DP,"); break; - case FLPOINTER: + case EEPPOINTER: fprintf (of,"DA,"); break; case ARRAY : fprintf (of,"DA%d,",DCL_ELEM(type)); break; + default: + break; } } else { switch (SPEC_NOUN(type)) { @@ -1705,6 +1735,9 @@ void cdbTypeInfo (link *type,FILE *of) case V_BIT: fprintf(of,"SB%d$%d",SPEC_BSTR(type),SPEC_BLEN(type)); break; + + default: + break; } fputs(":",of); if (SPEC_USIGN(type)) @@ -1852,6 +1885,23 @@ symbol *__conv[2][3][2]; link *floatType; +#if ENABLE_MICHAELH_REGPARM_HACK +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 ; + } +} +#endif + /*-----------------------------------------------------------------*/ /* initCSupport - create functions for C support routines */ /*-----------------------------------------------------------------*/ @@ -1907,11 +1957,11 @@ void initCSupport () for (su = 0; su < 2; su++) { if (tofrom) { sprintf(buffer, "__fs2%s%s", ssu[su], sbwd[bwd]); - __conv[tofrom][bwd][su] = funcOfType(buffer, __multypes[bwd][su], floatType, 2, options.float_rent); + __conv[tofrom][bwd][su] = funcOfType(buffer, __multypes[bwd][su], floatType, 1, options.float_rent); } else { sprintf(buffer, "__%s%s2fs", ssu[su], sbwd[bwd]); - __conv[tofrom][bwd][su] = funcOfType(buffer, floatType, __multypes[bwd][su], 2, options.float_rent); + __conv[tofrom][bwd][su] = funcOfType(buffer, floatType, __multypes[bwd][su], 1, options.float_rent); } } } @@ -1925,6 +1975,11 @@ 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 ENABLE_MICHAELH_REGPARM_HACK + if (bwd < 2) + _makeRegParam(__muldiv[muldivmod][bwd][su]); +#endif } } }