From 48cf52a951f5528d5833b3e496e404b733db336e Mon Sep 17 00:00:00 2001 From: sandeep Date: Sun, 10 Sep 2000 02:13:23 +0000 Subject: [PATCH] options.model specific fixes git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@349 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCBBlock.h | 4 ++-- src/SDCCdflow.c | 10 ++++----- src/SDCCmem.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++-- src/SDCCmem.h | 5 ++++- src/SDCCopt.c | 47 ++-------------------------------------- src/SDCCsymt.c | 2 +- 6 files changed, 68 insertions(+), 56 deletions(-) diff --git a/src/SDCCBBlock.h b/src/SDCCBBlock.h index 51d53726..b12a5e39 100644 --- a/src/SDCCBBlock.h +++ b/src/SDCCBBlock.h @@ -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 */ diff --git a/src/SDCCdflow.c b/src/SDCCdflow.c index 971ed998..76c2267a 100644 --- a/src/SDCCdflow.c +++ b/src/SDCCdflow.c @@ -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 */ diff --git a/src/SDCCmem.c b/src/SDCCmem.c index 616a3b78..2fb79e0b 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -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 */ /*-----------------------------------------------------------------*/ diff --git a/src/SDCCmem.h b/src/SDCCmem.h index 7a1009d1..1f4a54dc 100644 --- a/src/SDCCmem.h +++ b/src/SDCCmem.h @@ -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 diff --git a/src/SDCCopt.c b/src/SDCCopt.c index 3e1ff6fb..5e5afb9a 100644 --- a/src/SDCCopt.c +++ b/src/SDCCopt.c @@ -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))) */ diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index d7d64749..c91eb6a6 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -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; -- 2.30.2