1 /*-----------------------------------------------------------------*/
2 /* SDCCmem.c - 8051 memory management routines */
3 /*-----------------------------------------------------------------*/
8 memmap *xstack= NULL ; /* xternal stack data */
9 memmap *istack= NULL; /* internal stack */
10 memmap *code = NULL; /* code segment */
11 memmap *data = NULL; /* internal data upto 128 */
12 memmap *xdata = NULL; /* external data */
13 memmap *idata = NULL; /* internal data upto 256 */
14 memmap *bit = NULL; /* bit addressable space */
15 memmap *statsg= NULL; /* the constant data segment */
16 memmap *sfr = NULL; /* register space */
17 memmap *reg = NULL; /* register space */
18 memmap *sfrbit= NULL; /* sfr bit space */
19 memmap *generic=NULL; /* is a generic pointer */
20 memmap *overlay=NULL; /* overlay segment */
21 memmap *eeprom =NULL; /* eeprom location */
22 memmap *home =NULL; /* Unswitchable code bank */
24 /* this is a set of sets each set containing
25 symbols in a single overlay */
26 set *ovrSetSets = NULL;
28 extern set *operKeyReset ;
29 extern set *tmpfileSet ;
30 extern symbol *interrupts[];
32 int fatalError = 0 ;/* fatal error flag */
34 /*-----------------------------------------------------------------*/
35 /* allocMap - allocates a memory map */
36 /*-----------------------------------------------------------------*/
37 memmap *allocMap (char rspace, /* sfr space */
38 char farmap, /* far or near segment */
39 char paged , /* can this segment be paged */
40 char direct, /* directly addressable */
41 char bitaddr, /* bit addressable space*/
42 char codemap, /* this is code space */
43 unsigned sloc, /* starting location */
44 const char *name, /* 2 character name */
45 char dbName , /* debug name */
46 int ptrType /* pointer type for this space */
51 if (!(map = GC_malloc(sizeof(memmap)))) {
52 werror(E_OUT_OF_MEM,__FILE__,sizeof(memmap));
56 memset(map, ZERO, sizeof(memmap));
60 map->direct = direct ;
61 map->bitsp = bitaddr ;
62 map->codesp = codemap ;
65 map->dbName = dbName ;
66 map->ptrType= ptrType;
67 if (!(map->oFile = tempfile())) {
68 werror(E_TMPFILE_FAILED);
71 addSetHead (&tmpfileSet,map->oFile);
76 /*-----------------------------------------------------------------*/
77 /* initMem - allocates and initializes all the segments */
78 /*-----------------------------------------------------------------*/
81 /* allocate all the segments */
82 /* xternal stack segment ;
90 POINTER-TYPE - FPOINTER
92 xstack = allocMap (0, 1, 1, 0, 0, 0, options.xstack_loc, XSTACK_NAME,'A',PPOINTER);
94 /* internal stack segment ;
102 POINTER-TYPE - POINTER
104 istack = allocMap (0, 0, 0, 0, 0, 0,options.stack_loc, ISTACK_NAME,'B',POINTER);
114 POINTER-TYPE - CPOINTER
116 code = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME,'C',CPOINTER);
126 POINTER-TYPE - CPOINTER
128 home = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME,'C',CPOINTER);
130 /* Static segment (code for variables );
138 POINTER-TYPE - CPOINTER
140 statsg = allocMap (0, 1, 0, 0, 0, 1,0, STATIC_NAME,'D',CPOINTER);
142 /* Data segment - internal storage segment ;
150 POINTER-TYPE - POINTER
152 data = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME,'E',POINTER);
154 /* overlay segment - same as internal storage segment ;
162 POINTER-TYPE - POINTER
164 overlay = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME,'E',POINTER);
166 /* Xternal Data segment -
174 POINTER-TYPE - FPOINTER
176 xdata = allocMap (0, 1, 0, 0, 0, 0, options.xdata_loc, XDATA_NAME,'F',FPOINTER);
178 /* Inderectly addressed internal data segment
186 POINTER-TYPE - IPOINTER
188 idata = allocMap (0, 0, 0, 0, 0, 0, options.idata_loc,IDATA_NAME,'G',IPOINTER);
190 /* Static segment (code for variables );
198 POINTER-TYPE - _NONE_
200 bit = allocMap (0, 0, 0, 1, 1, 0,0, BIT_NAME,'H',0);
202 /* Special function register space :-
210 POINTER-TYPE - _NONE_
212 sfr = allocMap (1,0, 0, 1, 0, 0,0, REG_NAME,'I',0);
222 POINTER-TYPE - _NONE_
224 reg = allocMap (1,0, 0, 0, 0, 0, 0,REG_NAME,' ',0);
234 POINTER-TYPE - _NONE_
236 sfrbit = allocMap (1,0, 0, 1, 1, 0,0, REG_NAME,'J',0);
246 POINTER-TYPE - EEPPOINTER
248 eeprom = allocMap (0,1, 0, 0, 0, 0,0, REG_NAME,'K',EEPPOINTER);
250 /* the unknown map */
251 generic = allocMap (1,0, 0, 1, 1, 0,0, REG_NAME,' ',GPOINTER);
255 /*-----------------------------------------------------------------*/
256 /* allocIntoSeg - puts a symbol into a memory segment */
257 /*-----------------------------------------------------------------*/
258 void allocIntoSeg (symbol *sym)
260 memmap *segment = SPEC_OCLS(sym->etype);
261 addSet (&segment->syms,sym);
264 /*-----------------------------------------------------------------*/
265 /* allocGlobal - aassigns the output segment to a global var */
266 /*-----------------------------------------------------------------*/
267 void allocGlobal ( symbol *sym )
269 /* symbol name is internal name */
270 sprintf (sym->rname,"%s%s", port->fun_prefix, sym->name);
272 /* add it to the operandKey reset */
273 addSet(&operKeyReset,sym);
275 /* if this is a literal e.g. enumerated type */
276 /* put it in the data segment & do nothing */
277 if (IS_LITERAL(sym->etype)) {
278 SPEC_OCLS(sym->etype) = data ;
282 /* if this is a function then assign code space */
283 if (IS_FUNC(sym->type)) {
284 SPEC_OCLS(sym->etype) = code ;
285 /* if this is an interrupt service routine
286 then put it in the interrupt service array */
287 if (IS_ISR(sym->etype)) {
289 if (interrupts[SPEC_INTN(sym->etype)])
290 werror(E_INT_DEFINED,
291 SPEC_INTN(sym->etype),
292 interrupts[SPEC_INTN(sym->etype)]->name);
294 interrupts[SPEC_INTN(sym->etype)] = sym;
296 /* automagically extend the maximum interrupts */
297 if (SPEC_INTN(sym->etype) >= maxInterrupts )
298 maxInterrupts = SPEC_INTN(sym->etype) + 1;
300 /* if it is not compiler defined */
307 /* if this is a SFR or SBIT */
308 if ( SPEC_SCLS(sym->etype) == S_SFR ||
309 SPEC_SCLS(sym->etype) == S_SBIT ) {
311 /* if both absolute address & initial */
312 /* value specified then error */
313 if ( IS_ABSOLUTE (sym->etype) && sym->ival ) {
314 werror(E_SFR_INIT,sym->name);
318 SPEC_OCLS(sym->etype) =
319 (SPEC_SCLS(sym->etype) == S_SFR ? sfr : sfrbit);
325 /* if this is a bit variable and no storage class */
326 if ( SPEC_NOUN(sym->etype) == V_BIT
327 && SPEC_SCLS(sym->etype) == S_BIT ) {
328 SPEC_OCLS(sym->etype) = bit ;
333 /* if bit storage class */
334 if ( SPEC_SCLS(sym->etype) == S_SBIT ) {
335 SPEC_OCLS(sym->etype) = bit;
340 /* register storage class ignored changed to FIXED */
341 if ( SPEC_SCLS(sym->etype) == S_REGISTER )
342 SPEC_SCLS(sym->etype) = S_FIXED ;
344 /* if data specified then */
345 if (SPEC_SCLS(sym->etype) == S_DATA) {
346 /* set the output class */
347 SPEC_OCLS(sym->etype) = data ;
348 /* generate the symbol */
353 /* if it is fixed, then allocate depending on the */
354 /* current memory model,same for automatics */
355 if ( SPEC_SCLS(sym->etype) == S_FIXED ||
356 SPEC_SCLS(sym->etype) == S_AUTO ) {
357 /* set the output class */
358 SPEC_OCLS(sym->etype) = port->mem.default_globl_map ;
359 /* generate the symbol */
364 /* if code change to constant */
365 if ( SPEC_SCLS(sym->etype) == S_CODE ||
366 SPEC_SCLS(sym->etype) == S_CONSTANT ) {
367 SPEC_OCLS(sym->etype) = statsg ;
372 if ( SPEC_SCLS(sym->etype) == S_XDATA ) {
373 SPEC_OCLS(sym->etype) = xdata ;
378 if ( SPEC_SCLS(sym->etype) == S_IDATA ) {
379 SPEC_OCLS(sym->etype) = idata ;
385 if ( SPEC_SCLS(sym->etype) == S_EEPROM ) {
386 SPEC_OCLS(sym->etype) = eeprom ;
394 /*-----------------------------------------------------------------*/
395 /* allocParms - parameters are always passed on stack */
396 /*-----------------------------------------------------------------*/
397 void allocParms ( value *val )
402 for ( lval = val ; lval ; lval = lval->next, pNum++ ) {
404 /* check the declaration */
405 checkDecl (lval->sym);
407 /* if this a register parm then allocate
408 it as a local variable by adding it
409 to the first block we see in the body */
410 if (IS_REGPARM(lval->etype))
413 /* mark it as my parameter */
414 lval->sym->ismyparm = 1;
415 lval->sym->localof = currFunc;
418 /* if automatic variables r 2b stacked */
419 if ( options.stackAuto || IS_RENT(currFunc->etype)) {
422 lval->sym->onStack = 1;
424 /* choose which stack 2 use */
425 /* use xternal stack */
426 if ( options.useXstack ) {
427 /* PENDING: stack direction support */
428 SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = xstack ;
429 SPEC_STAK(lval->etype) = SPEC_STAK(lval->sym->etype) = lval->sym->stack =
430 xstackPtr - getSize(lval->type);
431 xstackPtr -= getSize (lval->type);
433 else { /* use internal stack */
434 SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = istack ;
435 if (port->stack.direction > 0) {
436 SPEC_STAK(lval->etype) = SPEC_STAK(lval->sym->etype) = lval->sym->stack =
437 stackPtr - ( SPEC_BANK(currFunc->etype) ? port->stack.bank_overhead : 0) -
438 getSize(lval->type) -
439 (IS_ISR(currFunc->etype) ? port->stack.isr_overhead : 0);
440 stackPtr -= getSize (lval->type);
443 /* This looks like the wrong order but it turns out OK... */
444 /* PENDING: isr, bank overhead, ... */
445 SPEC_STAK(lval->etype) = SPEC_STAK(lval->sym->etype) = lval->sym->stack =
447 (IS_BANKEDCALL(currFunc->etype) ? port->stack.banked_overhead : 0) +
448 (IS_ISR(currFunc->etype) ? port->stack.isr_overhead : 0) +
450 stackPtr += getSize (lval->type);
453 allocIntoSeg(lval->sym);
455 else { /* allocate them in the automatic space */
456 /* generate a unique name */
457 sprintf (lval->sym->rname,"%s%s_PARM_%d", port->fun_prefix, currFunc->name,pNum);
458 strcpy (lval->name,lval->sym->rname);
460 /* if declared in external storage */
461 if (SPEC_SCLS(lval->etype) == S_XDATA)
462 SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) = xdata;
464 /* other wise depending on the memory model
465 note here that we put it into the overlay segment
466 first, we will remove it from the overlay segment
467 after the overlay determination has been done */
468 SPEC_OCLS(lval->etype) = SPEC_OCLS(lval->sym->etype) =
469 ( options.model == MODEL_SMALL ? port->mem.default_local_map :
470 (options.noOverlay ? port->mem.default_local_map
473 allocIntoSeg(lval->sym);
480 /*-----------------------------------------------------------------*/
481 /* deallocParms - parameters are always passed on stack */
482 /*-----------------------------------------------------------------*/
483 void deallocParms ( value *val )
487 for ( lval = val ; lval ; lval = lval->next ) {
489 /* unmark is myparm */
490 lval->sym->ismyparm = 0;
491 /* if on stack then depending on which stack */
493 /* delete it from the symbol table */
494 deleteSym (SymbolTab,lval->sym,lval->sym->name);
496 if (!lval->sym->isref) {
497 lval->sym->allocreq = 1;
498 werror(W_NO_REFERENCE,currFunc->name,
499 "function argument",lval->sym->name);
502 /* move the rname if any to the name for both val & sym */
503 /* and leave a copy of it in the symbol table */
504 if (lval->sym->rname[0]) {
505 char buffer[SDCC_NAME_MAX];
506 strcpy(buffer,lval->sym->rname);
507 lval->sym = copySymbol(lval->sym);
508 strcpy(lval->sym->rname,buffer);
509 strcpy(lval->name,strcpy(lval->sym->name,lval->sym->rname));
510 addSym (SymbolTab, lval->sym, lval->sym->name,
511 lval->sym->level,lval->sym->block);
512 lval->sym->_isparm = 1;
513 addSet(&operKeyReset,lval->sym);
521 /*-----------------------------------------------------------------*/
522 /* allocLocal - allocate local variables */
523 /*-----------------------------------------------------------------*/
524 void allocLocal ( symbol *sym )
527 /* generate an unique name */
528 sprintf(sym->rname,"%s%s_%s_%d_%d",
530 currFunc->name,sym->name,sym->level,sym->block);
533 sym->localof = currFunc;
535 /* if this is a static variable */
536 if ( IS_STATIC (sym->etype)) {
537 SPEC_OCLS(sym->etype) = port->mem.default_local_map;
543 /* if volatile then */
544 if (IS_VOLATILE(sym->etype))
547 /* this is automatic */
549 /* if it to be placed on the stack */
550 if ( options.stackAuto || reentrant) {
553 if ( options.useXstack ) {
554 /* PENDING: stack direction for xstack */
555 SPEC_OCLS(sym->etype) = xstack ;
556 SPEC_STAK(sym->etype) = sym->stack = (xstackPtr + 1);
557 xstackPtr += getSize (sym->type) ;
560 SPEC_OCLS(sym->etype) = istack ;
561 if (port->stack.direction > 0) {
562 SPEC_STAK(sym->etype) = sym->stack = ( stackPtr + 1);
563 stackPtr += getSize (sym->type) ;
566 stackPtr -= getSize (sym->type);
567 SPEC_STAK(sym->etype) = sym->stack = stackPtr;
574 /* else depending on the storage class specified */
575 if ( SPEC_SCLS(sym->etype) == S_XDATA ) {
576 SPEC_OCLS(sym->etype) = xdata ;
581 if ( (SPEC_SCLS(sym->etype) == S_CODE ||
582 SPEC_SCLS(sym->etype) == S_CONSTANT) &&
584 SPEC_OCLS(sym->etype) = statsg ;
589 if ( SPEC_SCLS(sym->etype) == S_IDATA ) {
590 SPEC_OCLS(sym->etype) = idata ;
596 /* if this is a function then assign code space */
597 if (IS_FUNC(sym->type)) {
598 SPEC_OCLS(sym->etype) = code ;
602 /* if this is a SFR or SBIT */
603 if ( SPEC_SCLS(sym->etype) == S_SFR ||
604 SPEC_SCLS(sym->etype) == S_SBIT ) {
606 /* if both absolute address & initial */
607 /* value specified then error */
608 if ( IS_ABSOLUTE (sym->etype) && sym->ival ) {
609 werror(E_SFR_INIT,sym->name);
613 SPEC_OCLS(sym->etype) =
614 (SPEC_SCLS(sym->etype) == S_SFR ? sfr : sfrbit);
620 /* if this is a bit variable and no storage class */
621 if ( SPEC_NOUN(sym->etype) == V_BIT
622 && (SPEC_SCLS(sym->etype) == S_BIT)) {
623 SPEC_OCLS(sym->etype) = bit ;
628 if ( SPEC_SCLS(sym->etype) == S_DATA ) {
629 SPEC_OCLS(sym->etype) = (options.noOverlay ? data : overlay );
634 if ( SPEC_SCLS(sym->etype) == S_EEPROM ) {
635 SPEC_OCLS(sym->etype) = eeprom;
640 /* again note that we have put it into the overlay segment
641 will remove and put into the 'data' segment if required after
642 overlay analysis has been done */
643 SPEC_OCLS(sym->etype) = ( options.model == MODEL_SMALL ? port->mem.default_local_map :
644 (options.noOverlay ? port->mem.default_local_map
649 /*-----------------------------------------------------------------*/
650 /* deallocLocal - deallocates the local variables */
651 /*-----------------------------------------------------------------*/
652 void deallocLocal ( symbol *csym )
656 for ( sym = csym ; sym ; sym = sym->next) {
660 /* if it is on the stack */
662 if (options.useXstack)
663 xstackPtr -= getSize(sym->type);
665 stackPtr -= getSize(sym->type);
667 /* if not used give a warning */
668 if (!sym->isref && !IS_STATIC(sym->etype))
669 werror(W_NO_REFERENCE,currFunc->name,
670 "local variable",sym->name);
671 /* now delete it from the symbol table */
672 deleteSym (SymbolTab,sym,sym->name);
676 /*-----------------------------------------------------------------*/
677 /* overlay2data - moves declarations from the overlay seg to data */
678 /*-----------------------------------------------------------------*/
683 for (sym = setFirstItem(overlay->syms); sym;
684 sym = setNextItem(overlay->syms)) {
686 SPEC_OCLS(sym->etype) = data;
690 setToNull((void **) &overlay->syms);
694 /*-----------------------------------------------------------------*/
695 /* overlay2Set - will add all symbols from the overlay segment to */
696 /* the set of sets containing the overlable symbols */
697 /*-----------------------------------------------------------------*/
703 for (sym = setFirstItem(overlay->syms); sym;
704 sym = setNextItem(overlay->syms)) {
709 setToNull((void **) &overlay->syms);
710 addSet (&ovrSetSets,oset);
714 /*-----------------------------------------------------------------*/
715 /* allocVariables - creates decl & assign storage class for a v */
716 /*-----------------------------------------------------------------*/
717 int allocVariables ( symbol *symChain )
724 /* go thru the symbol chain */
725 for ( sym = symChain ; sym ; sym = sym->next ) {
727 /* if this is a typedef then add it */
728 /* to the typedef table */
729 if (IS_TYPEDEF(sym->etype)) {
730 /* check if the typedef already exists */
731 csym = findSym (TypedefTab, NULL, sym->name );
732 if ( csym && csym->level == sym->level )
733 werror(E_DUPLICATE_TYPEDEF,sym->name);
735 addSym (TypedefTab, sym , sym->name,sym->level,sym->block);
736 continue ; /* go to the next one */
738 /* make sure it already exist */
739 csym = findSymWithLevel (SymbolTab, sym);
740 if (! csym || (csym && csym->level != sym->level) )
743 /* check the declaration */
746 /* if this is a function or a pointer to function */
747 /* then args processing */
748 if (funcInChain(csym->type)) {
750 processFuncArgs (csym, 1);
751 /* if register bank specified then update maxRegBank */
752 if (maxRegBank < SPEC_BANK(csym->etype))
753 maxRegBank = SPEC_BANK(csym->etype);
756 /* if this is a extern variable then change the */
757 /* level to zero temporarily */
758 if (IS_EXTERN(csym->etype) || IS_FUNC(csym->type) ) {
759 saveLevel = csym->level ;
763 /* if this is a literal then it is an enumerated */
764 /* type so need not allocate it space for it */
765 if (IS_LITERAL(sym->etype))
768 /* generate the actual declaration */
772 stack += getSize(csym->type) ;
777 /* restore the level */
778 if (IS_EXTERN(csym->etype) || IS_FUNC(csym->type))
779 csym->level = saveLevel;
785 /*-----------------------------------------------------------------*/
786 /* redoStackOffsets :- will reassign the values for stack offsets */
787 /*-----------------------------------------------------------------*/
788 void redoStackOffsets ()
794 /* after register allocation is complete we know
795 which variables will need to be assigned space
796 on the stack. We will eliminate those variables
797 which do not have the allocReq flag thus reducing
799 for ( sym = setFirstItem(istack->syms); sym;
800 sym = setNextItem(istack->syms)) {
802 int size = getSize(sym->type);
803 /* nothing to do with parameters so continue */
804 if ((sym->_isparm && !IS_REGPARM(sym->etype)))
807 if ( IS_AGGREGATE(sym->type)) {
808 if (port->stack.direction > 0) {
809 SPEC_STAK(sym->etype) = sym->stack = ( sPtr + 1);
814 SPEC_STAK(sym->etype) = sym->stack = sPtr;
819 /* if allocation not required then subtract
820 size from overall stack size & continue */
821 if (!sym->allocreq) {
822 currFunc->stack -= size;
823 SPEC_STAK(currFunc->etype) -= size;
827 if (port->stack.direction > 0) {
828 SPEC_STAK(sym->etype) = sym->stack = ( sPtr + 1);
833 SPEC_STAK(sym->etype) = sym->stack = sPtr;
837 /* do the same for the external stack */
839 for ( sym = setFirstItem(xstack->syms); sym;
840 sym = setNextItem(xstack->syms)) {
842 int size = getSize(sym->type);
843 /* nothing to do with parameters so continue */
844 if ((sym->_isparm && !IS_REGPARM(sym->etype)))
847 if (IS_AGGREGATE(sym->type)) {
848 SPEC_STAK(sym->etype) = sym->stack = ( xsPtr + 1);
853 /* if allocation not required then subtract
854 size from overall stack size & continue */
855 if (!sym->allocreq) {
856 currFunc->xstack -= size;
857 SPEC_STAK(currFunc->etype) -= size;
861 SPEC_STAK(sym->etype) = sym->stack = ( xsPtr + 1);
865 /* if the debug option is set then output the
866 symbols to the map file */
867 if (options.debug && !options.nodebug) {
868 for (sym = setFirstItem(istack->syms); sym;
869 sym = setNextItem(istack->syms))
870 cdbSymbol(sym,cdbFile,FALSE,FALSE);
872 for (sym = setFirstItem(xstack->syms); sym;
873 sym = setNextItem(xstack->syms))
874 cdbSymbol(sym,cdbFile,FALSE,FALSE);
878 /*-----------------------------------------------------------------*/
879 /* printAllocInfoSeg- print the allocation for a given section */
880 /*-----------------------------------------------------------------*/
881 static void printAllocInfoSeg ( memmap *map, symbol *func, FILE *of)
886 if (!map->syms) return;
888 for (sym = setFirstItem(map->syms); sym;
889 sym = setNextItem(map->syms)) {
891 if (sym->level == 0) continue;
892 if (sym->localof != func) continue ;
893 fprintf(of,";%-25s Allocated to ",sym->name);
895 /* if assigned to registers */
896 if (!sym->allocreq && sym->reqv) {
898 sym = OP_SYMBOL(sym->reqv);
899 fprintf(of,"registers ");
900 for (i = 0 ; i < 4 && sym->regs[i] ; i++)
901 fprintf(of,"%s ",port->getRegName(sym->regs[i]));
908 fprintf(of,"stack - offset %d\n",sym->stack);
912 /* otherwise give rname */
913 fprintf(of,"in memory with name '%s'\n",sym->rname);
917 /*-----------------------------------------------------------------*/
918 /* canOverlayLocals - returns true if the local variables can overlayed */
919 /*-----------------------------------------------------------------*/
920 static bool canOverlayLocals (eBBlock **ebbs, int count)
923 /* if staticAuto is in effect or the current function
924 being compiled is reentrant or the overlay segment
925 is empty or no overlay option is in effect then */
926 if (options.noOverlay ||
929 (IS_RENT(currFunc->etype) ||
930 IS_ISR(currFunc->etype))) ||
931 elementsInSet(overlay->syms) == 0)
935 /* otherwise do thru the blocks and see if there
936 any function calls if found then return false */
937 for (i = 0; i < count ; i++ ) {
940 for (ic = ebbs[i]->sch; ic ; ic = ic->next)
941 if (ic && ( ic->op == CALL || ic->op == PCALL))
945 /* no function calls found return TRUE */
949 /*-----------------------------------------------------------------*/
950 /* doOverlays - move the overlay segment to appropriate location */
951 /*-----------------------------------------------------------------*/
952 void doOverlays( eBBlock **ebbs, int count)
954 /* check if the parameters and local variables
955 of this function can be put in the overlay segment
956 This check is essentially to see if the function
957 calls any other functions if yes then we cannot
959 if (canOverlayLocals(ebbs,count))
960 /* if we can then put the parameters &
961 local variables in the overlay set */
964 /* otherwise put them into data where
969 /*-----------------------------------------------------------------*/
970 /* printAllocInfo - prints allocation information for a function */
971 /*-----------------------------------------------------------------*/
972 void printAllocInfo( symbol * func, FILE *of)
974 if (!of) of = stdout;
976 /* must be called after register allocation is complete */
977 fprintf(of,";------------------------------------------------------------\n");
978 fprintf(of,";Allocation info for local variables in function '%s'\n",func->name);
979 fprintf(of,";------------------------------------------------------------\n");
981 printAllocInfoSeg(xstack,func,of);
982 printAllocInfoSeg(istack,func,of);
983 printAllocInfoSeg(code,func,of);
984 printAllocInfoSeg(data,func,of);
985 printAllocInfoSeg(xdata,func,of);
986 printAllocInfoSeg(idata,func,of);
987 printAllocInfoSeg(sfr,func,of);
988 printAllocInfoSeg(sfrbit,func,of);