#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 */
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 */
/* 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 */
/* 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 */
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 ));
/* 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);
}
}
+/*-----------------------------------------------------------------*/
+/* 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 */
/*-----------------------------------------------------------------*/
struct set ;
struct value ;
+struct eBBlock;
+
typedef struct memmap{
unsigned char pageno; /* page no for this variable */
const char *sname; /* character prefix for map */
void overlay2Set ( );
void overlay2data ( );
void redoStackOffsets( );
-void printAllocInfo (struct symbol *, FILE *);
+void printAllocInfo (struct symbol *, FILE * );
+void doOverlays (struct eBBlock **, int count );
#endif
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 */
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);
return NULL;
}
+
+
/* (add-hook 'c-mode-hook (lambda () (setq c-basic-offset 4))) */
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;