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 *xidata = NULL; /* the initialized xdata */
14 memmap *xinit = NULL; /* the initializers for xidata */
15 memmap *idata = NULL; /* internal data upto 256 */
16 memmap *bit = NULL; /* bit addressable space */
17 memmap *statsg = NULL; /* the constant data segment */
18 memmap *sfr = NULL; /* register space */
19 memmap *reg = NULL; /* register space */
20 memmap *sfrbit = NULL; /* sfr bit space */
21 memmap *generic = NULL; /* is a generic pointer */
22 memmap *overlay = NULL; /* overlay segment */
23 memmap *eeprom = NULL; /* eeprom location */
24 memmap *home = NULL; /* Unswitchable code bank */
26 /* this is a set of sets each set containing
27 symbols in a single overlay */
28 set *ovrSetSets = NULL;
31 int fatalError = 0; /* fatal error flag */
33 /*-----------------------------------------------------------------*/
34 /* allocMap - allocates a memory map */
35 /*-----------------------------------------------------------------*/
37 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 = Safe_alloc (sizeof (memmap))))
53 werror (E_OUT_OF_MEM, __FILE__, sizeof (memmap));
57 memset (map, ZERO, sizeof (memmap));
63 map->codesp = codemap;
67 map->ptrType = ptrType;
68 if (!(map->oFile = tempfile ()))
70 werror (E_TMPFILE_FAILED);
73 addSetHead (&tmpfileSet, map->oFile);
78 /*-----------------------------------------------------------------*/
79 /* initMem - allocates and initializes all the segments */
80 /*-----------------------------------------------------------------*/
84 /* allocate all the segments */
85 /* xternal stack segment ;
93 POINTER-TYPE - FPOINTER
95 xstack = allocMap (0, 1, 1, 0, 0, 0, options.xstack_loc, XSTACK_NAME, 'A', PPOINTER);
97 /* internal stack segment ;
105 POINTER-TYPE - POINTER
107 istack = allocMap (0, 0, 0, 0, 0, 0, options.stack_loc, ISTACK_NAME, 'B', POINTER);
117 POINTER-TYPE - CPOINTER
119 code = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER);
129 POINTER-TYPE - CPOINTER
131 home = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER);
133 /* Static segment (code for variables );
141 POINTER-TYPE - CPOINTER
143 statsg = allocMap (0, 1, 0, 0, 0, 1, 0, STATIC_NAME, 'D', CPOINTER);
145 /* Data segment - internal storage segment ;
153 POINTER-TYPE - POINTER
155 data = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
157 /* overlay segment - same as internal storage segment ;
165 POINTER-TYPE - POINTER
167 overlay = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
169 /* Xternal Data segment -
177 POINTER-TYPE - FPOINTER
179 xdata = allocMap (0, 1, 0, 0, 0, 0, options.xdata_loc, XDATA_NAME, 'F', FPOINTER);
180 xidata = allocMap (0, 1, 0, 0, 0, 0, 0, XIDATA_NAME, 'F', FPOINTER);
181 xinit = allocMap (0, 1, 0, 0, 0, 1, 0, XINIT_NAME, 'C', CPOINTER);
183 /* Inderectly addressed internal data segment
191 POINTER-TYPE - IPOINTER
193 idata = allocMap (0, 0, 0, 0, 0, 0, options.idata_loc, IDATA_NAME, 'G', IPOINTER);
195 /* Static segment (code for variables );
203 POINTER-TYPE - _NONE_
205 bit = allocMap (0, 0, 0, 1, 1, 0, 0, BIT_NAME, 'H', 0);
207 /* Special function register space :-
215 POINTER-TYPE - _NONE_
217 sfr = allocMap (1, 0, 0, 1, 0, 0, 0, REG_NAME, 'I', 0);
227 POINTER-TYPE - _NONE_
229 reg = allocMap (1, 0, 0, 0, 0, 0, 0, REG_NAME, ' ', 0);
239 POINTER-TYPE - _NONE_
241 sfrbit = allocMap (1, 0, 0, 1, 1, 0, 0, REG_NAME, 'J', 0);
251 POINTER-TYPE - EEPPOINTER
253 eeprom = allocMap (0, 1, 0, 0, 0, 0, 0, REG_NAME, 'K', EEPPOINTER);
255 /* the unknown map */
256 generic = allocMap (1, 0, 0, 1, 1, 0, 0, REG_NAME, ' ', GPOINTER);
260 /*-----------------------------------------------------------------*/
261 /* allocIntoSeg - puts a symbol into a memory segment */
262 /*-----------------------------------------------------------------*/
264 allocIntoSeg (symbol * sym)
266 memmap *segment = SPEC_OCLS (sym->etype);
267 addSet (&segment->syms, sym);
270 /*-----------------------------------------------------------------*/
271 /* deleteFromSeg - deletes a symbol from segment used when a var */
272 /* firest declared as "extern" then no extern */
273 /*-----------------------------------------------------------------*/
274 void deleteFromSeg(symbol *sym)
276 if (SPEC_OCLS(sym->etype)) {
277 memmap *segment = SPEC_OCLS (sym->etype);
278 deleteSetItem(&segment->syms,sym);
283 /*-----------------------------------------------------------------*/
284 /* allocGlobal - assigns the output segment to a global var */
285 /*-----------------------------------------------------------------*/
287 allocGlobal (symbol * sym)
290 /* symbol name is internal name */
291 if (!sym->level) /* local statics can come here */
292 sprintf (sym->rname, "%s%s", port->fun_prefix, sym->name);
294 /* add it to the operandKey reset */
295 addSet (&operKeyReset, sym);
297 /* if this is a literal e.g. enumerated type */
298 /* put it in the data segment & do nothing */
299 if (IS_LITERAL (sym->etype))
301 SPEC_OCLS (sym->etype) = data;
305 /* if this is a function then assign code space */
306 if (IS_FUNC (sym->type))
308 SPEC_OCLS (sym->etype) = code;
309 /* if this is an interrupt service routine
310 then put it in the interrupt service array */
311 if (FUNC_ISISR (sym->type))
314 if (interrupts[FUNC_INTNO (sym->type)])
315 werror (E_INT_DEFINED,
316 FUNC_INTNO (sym->type),
317 interrupts[FUNC_INTNO (sym->type)]->name);
319 interrupts[FUNC_INTNO (sym->type)] = sym;
321 /* automagically extend the maximum interrupts */
322 if (FUNC_INTNO (sym->type) >= maxInterrupts)
323 maxInterrupts = FUNC_INTNO (sym->type) + 1;
325 /* if it is not compiler defined */
332 /* if this is a SFR or SBIT */
333 if (SPEC_SCLS (sym->etype) == S_SFR ||
334 SPEC_SCLS (sym->etype) == S_SBIT)
337 /* if both absolute address & initial */
338 /* value specified then error */
339 if (IS_ABSOLUTE (sym->etype) && sym->ival)
341 werror (E_SFR_INIT, sym->name);
345 SPEC_OCLS (sym->etype) =
346 (SPEC_SCLS (sym->etype) == S_SFR ? sfr : sfrbit);
352 /* if this is a bit variable and no storage class */
353 if (SPEC_NOUN (sym->etype) == V_BIT
354 && SPEC_SCLS (sym->etype) == S_BIT)
356 SPEC_OCLS (sym->etype) = bit;
361 /* if bit storage class */
362 if (SPEC_SCLS (sym->etype) == S_SBIT)
364 SPEC_OCLS (sym->etype) = bit;
369 /* register storage class ignored changed to FIXED */
370 if (SPEC_SCLS (sym->etype) == S_REGISTER)
371 SPEC_SCLS (sym->etype) = S_FIXED;
373 /* if data specified then */
374 if (SPEC_SCLS (sym->etype) == S_DATA)
376 /* set the output class */
377 SPEC_OCLS (sym->etype) = data;
378 /* generate the symbol */
383 /* if it is fixed, then allocate depending on the */
384 /* current memory model, same for automatics */
385 if (SPEC_SCLS (sym->etype) == S_FIXED ||
386 SPEC_SCLS (sym->etype) == S_AUTO) {
387 if (port->mem.default_globl_map != xdata) {
388 /* set the output class */
389 SPEC_OCLS (sym->etype) = port->mem.default_globl_map;
390 /* generate the symbol */
394 SPEC_SCLS (sym->etype) = S_XDATA;
398 /* if code change to constant */
399 if (SPEC_SCLS (sym->etype) == S_CODE) {
400 SPEC_OCLS (sym->etype) = statsg;
405 if (SPEC_SCLS (sym->etype) == S_XDATA)
407 // should we move this to the initialized data segment?
408 if (port->genXINIT &&
409 sym->ival && (sym->level==0) && !SPEC_ABSA(sym->etype)) {
410 SPEC_OCLS(sym->etype)=xidata;
412 SPEC_OCLS (sym->etype) = xdata;
418 if (SPEC_SCLS (sym->etype) == S_IDATA)
420 SPEC_OCLS (sym->etype) = idata;
426 if (SPEC_SCLS (sym->etype) == S_EEPROM)
428 SPEC_OCLS (sym->etype) = eeprom;
436 /*-----------------------------------------------------------------*/
437 /* allocParms - parameters are always passed on stack */
438 /*-----------------------------------------------------------------*/
440 allocParms (value * val)
445 for (lval = val; lval; lval = lval->next, pNum++)
448 /* check the declaration */
449 checkDecl (lval->sym, 0);
451 /* if this a register parm then allocate
452 it as a local variable by adding it
453 to the first block we see in the body */
454 if (IS_REGPARM (lval->etype))
457 /* mark it as my parameter */
458 lval->sym->ismyparm = 1;
459 lval->sym->localof = currFunc;
462 /* if automatic variables r 2b stacked */
463 if (options.stackAuto || IFFUNC_ISREENT (currFunc->type))
467 lval->sym->onStack = 1;
469 /* choose which stack 2 use */
470 /* use xternal stack */
471 if (options.useXstack)
473 /* PENDING: stack direction support */
474 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = xstack;
475 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
476 xstackPtr - getSize (lval->type);
477 xstackPtr -= getSize (lval->type);
480 { /* use internal stack */
481 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = istack;
482 if (port->stack.direction > 0)
484 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
485 stackPtr - (FUNC_REGBANK (currFunc->type) ? port->stack.bank_overhead : 0) -
486 getSize (lval->type) -
487 (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0);
488 stackPtr -= getSize (lval->type);
492 /* This looks like the wrong order but it turns out OK... */
493 /* PENDING: isr, bank overhead, ... */
494 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
496 ((IFFUNC_ISBANKEDCALL (currFunc->type) && !SPEC_STAT(getSpec(currFunc->etype)))? port->stack.banked_overhead : 0) +
497 (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0) +
499 stackPtr += getSize (lval->type);
502 allocIntoSeg (lval->sym);
505 { /* allocate them in the automatic space */
506 /* generate a unique name */
507 sprintf (lval->sym->rname, "%s%s_PARM_%d", port->fun_prefix, currFunc->name, pNum);
508 strcpy (lval->name, lval->sym->rname);
510 /* if declared in external storage */
511 if (SPEC_SCLS (lval->etype) == S_XDATA)
512 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = xdata;
514 /* other wise depending on the memory model
515 note here that we put it into the overlay segment
516 first, we will remove it from the overlay segment
517 after the overlay determination has been done */
518 if (options.model == MODEL_SMALL)
520 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
521 (options.noOverlay ? port->mem.default_local_map
526 SPEC_SCLS (lval->etype) = S_XDATA;
527 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = xdata;
529 allocIntoSeg (lval->sym);
536 /*-----------------------------------------------------------------*/
537 /* deallocParms - parameters are always passed on stack */
538 /*-----------------------------------------------------------------*/
540 deallocParms (value * val)
544 for (lval = val; lval; lval = lval->next)
547 /* unmark is myparm */
548 lval->sym->ismyparm = 0;
550 /* delete it from the symbol table */
551 deleteSym (SymbolTab, lval->sym, lval->sym->name);
553 if (!lval->sym->isref)
555 lval->sym->allocreq = 0;
556 werror (W_NO_REFERENCE, currFunc->name,
557 "function argument", lval->sym->name);
560 /* move the rname if any to the name for both val & sym */
561 /* and leave a copy of it in the symbol table */
562 if (lval->sym->rname[0])
564 char buffer[SDCC_NAME_MAX];
565 strcpy (buffer, lval->sym->rname);
566 lval->sym = copySymbol (lval->sym);
567 strcpy (lval->sym->rname, buffer);
568 strcpy (lval->name, strcpy (lval->sym->name, lval->sym->rname));
569 addSym (SymbolTab, lval->sym, lval->sym->name,
570 lval->sym->level, lval->sym->block, 1);
571 lval->sym->_isparm = 1;
572 addSet (&operKeyReset, lval->sym);
580 /*-----------------------------------------------------------------*/
581 /* allocLocal - allocate local variables */
582 /*-----------------------------------------------------------------*/
584 allocLocal (symbol * sym)
587 /* generate an unique name */
588 sprintf (sym->rname, "%s%s_%s_%d_%d",
590 currFunc->name, sym->name, sym->level, sym->block);
593 sym->localof = currFunc;
595 /* if this is a static variable */
596 if (IS_STATIC (sym->etype))
603 /* if volatile then */
604 if (IS_VOLATILE (sym->etype))
607 /* this is automatic */
609 /* if it to be placed on the stack */
610 if (options.stackAuto || reentrant) {
612 if (options.useXstack) {
613 /* PENDING: stack direction for xstack */
614 SPEC_OCLS (sym->etype) = xstack;
615 SPEC_STAK (sym->etype) = sym->stack = (xstackPtr + 1);
616 xstackPtr += getSize (sym->type);
618 SPEC_OCLS (sym->etype) = istack;
619 if (port->stack.direction > 0) {
620 SPEC_STAK (sym->etype) = sym->stack = (stackPtr + 1);
621 stackPtr += getSize (sym->type);
623 stackPtr -= getSize (sym->type);
624 SPEC_STAK (sym->etype) = sym->stack = stackPtr;
631 /* else depending on the storage class specified */
632 if (SPEC_SCLS (sym->etype) == S_XDATA)
634 SPEC_OCLS (sym->etype) = xdata;
639 if (SPEC_SCLS (sym->etype) == S_CODE && !sym->_isparm) {
640 SPEC_OCLS (sym->etype) = statsg;
645 if (SPEC_SCLS (sym->etype) == S_IDATA)
647 SPEC_OCLS (sym->etype) = idata;
653 /* if this is a function then assign code space */
654 if (IS_FUNC (sym->type))
656 SPEC_OCLS (sym->etype) = code;
660 /* if this is a SFR or SBIT */
661 if (SPEC_SCLS (sym->etype) == S_SFR ||
662 SPEC_SCLS (sym->etype) == S_SBIT)
665 /* if both absolute address & initial */
666 /* value specified then error */
667 if (IS_ABSOLUTE (sym->etype) && sym->ival)
669 werror (E_SFR_INIT, sym->name);
673 SPEC_OCLS (sym->etype) =
674 (SPEC_SCLS (sym->etype) == S_SFR ? sfr : sfrbit);
680 /* if this is a bit variable and no storage class */
681 if (SPEC_NOUN (sym->etype) == V_BIT
682 && (SPEC_SCLS (sym->etype) == S_BIT))
684 SPEC_OCLS (sym->etype) = bit;
689 if (SPEC_SCLS (sym->etype) == S_DATA)
691 SPEC_OCLS (sym->etype) = (options.noOverlay ? data : overlay);
696 if (SPEC_SCLS (sym->etype) == S_EEPROM)
698 SPEC_OCLS (sym->etype) = eeprom;
703 /* again note that we have put it into the overlay segment
704 will remove and put into the 'data' segment if required after
705 overlay analysis has been done */
706 if (options.model == MODEL_SMALL) {
707 SPEC_OCLS (sym->etype) =
708 (options.noOverlay ? port->mem.default_local_map
711 SPEC_OCLS (sym->etype) = port->mem.default_local_map;
716 /*-----------------------------------------------------------------*/
717 /* deallocLocal - deallocates the local variables */
718 /*-----------------------------------------------------------------*/
720 deallocLocal (symbol * csym)
724 for (sym = csym; sym; sym = sym->next)
729 /* if it is on the stack */
732 if (options.useXstack)
733 xstackPtr -= getSize (sym->type);
735 stackPtr -= getSize (sym->type);
737 /* if not used give a warning */
738 if (!sym->isref && !IS_STATIC (sym->etype))
739 werror (W_NO_REFERENCE, currFunc->name,
740 "local variable", sym->name);
741 /* now delete it from the symbol table */
742 deleteSym (SymbolTab, sym, sym->name);
746 /*-----------------------------------------------------------------*/
747 /* overlay2data - moves declarations from the overlay seg to data */
748 /*-----------------------------------------------------------------*/
754 for (sym = setFirstItem (overlay->syms); sym;
755 sym = setNextItem (overlay->syms))
758 SPEC_OCLS (sym->etype) = data;
762 setToNull ((void **) &overlay->syms);
766 /*-----------------------------------------------------------------*/
767 /* overlay2Set - will add all symbols from the overlay segment to */
768 /* the set of sets containing the overlable symbols */
769 /*-----------------------------------------------------------------*/
776 for (sym = setFirstItem (overlay->syms); sym;
777 sym = setNextItem (overlay->syms))
783 setToNull ((void **) &overlay->syms);
784 addSet (&ovrSetSets, oset);
788 /*-----------------------------------------------------------------*/
789 /* allocVariables - creates decl & assign storage class for a v */
790 /*-----------------------------------------------------------------*/
792 allocVariables (symbol * symChain)
799 /* go thru the symbol chain */
800 for (sym = symChain; sym; sym = sym->next)
803 /* if this is a typedef then add it */
804 /* to the typedef table */
805 if (IS_TYPEDEF (sym->etype))
807 /* check if the typedef already exists */
808 csym = findSym (TypedefTab, NULL, sym->name);
809 if (csym && csym->level == sym->level)
810 werror (E_DUPLICATE_TYPEDEF, sym->name);
812 addSym (TypedefTab, sym, sym->name, sym->level, sym->block, 0);
813 continue; /* go to the next one */
815 /* make sure it already exist */
816 csym = findSymWithLevel (SymbolTab, sym);
817 if (!csym || (csym && csym->level != sym->level))
820 /* check the declaration */
823 /* if this is a function or a pointer to function */
824 /* then args processing */
825 if (funcInChain (csym->type))
827 #if 1 // jwk: TODO should have been done already in addDecl() (oclass????)
828 processFuncArgs (csym);
830 /* if register bank specified then update maxRegBank */
831 if (maxRegBank < FUNC_REGBANK (csym->type))
832 maxRegBank = FUNC_REGBANK (csym->type);
835 /* if this is a extern variable then change the */
836 /* level to zero temporarily */
837 if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
839 saveLevel = csym->level;
843 /* if this is a literal then it is an enumerated */
844 /* type so need not allocate it space for it */
845 if (IS_LITERAL (sym->etype))
848 /* generate the actual declaration */
853 stack += getSize (csym->type);
858 /* restore the level */
859 if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
860 csym->level = saveLevel;
866 /*-----------------------------------------------------------------*/
867 /* redoStackOffsets :- will reassign the values for stack offsets */
868 /*-----------------------------------------------------------------*/
870 redoStackOffsets (void)
876 /* after register allocation is complete we know
877 which variables will need to be assigned space
878 on the stack. We will eliminate those variables
879 which do not have the allocReq flag thus reducing
881 for (sym = setFirstItem (istack->syms); sym;
882 sym = setNextItem (istack->syms))
885 int size = getSize (sym->type);
886 /* nothing to do with parameters so continue */
887 if ((sym->_isparm && !IS_REGPARM (sym->etype)))
890 if (IS_AGGREGATE (sym->type))
892 if (port->stack.direction > 0)
894 SPEC_STAK (sym->etype) = sym->stack = (sPtr + 1);
900 SPEC_STAK (sym->etype) = sym->stack = sPtr;
905 /* if allocation not required then subtract
906 size from overall stack size & continue */
909 currFunc->stack -= size;
910 SPEC_STAK (currFunc->etype) -= size;
914 if (port->stack.direction > 0)
916 SPEC_STAK (sym->etype) = sym->stack = (sPtr + 1);
922 SPEC_STAK (sym->etype) = sym->stack = sPtr;
926 /* do the same for the external stack */
928 for (sym = setFirstItem (xstack->syms); sym;
929 sym = setNextItem (xstack->syms))
932 int size = getSize (sym->type);
933 /* nothing to do with parameters so continue */
934 if ((sym->_isparm && !IS_REGPARM (sym->etype)))
937 if (IS_AGGREGATE (sym->type))
939 SPEC_STAK (sym->etype) = sym->stack = (xsPtr + 1);
944 /* if allocation not required then subtract
945 size from overall stack size & continue */
948 currFunc->xstack -= size;
949 SPEC_STAK (currFunc->etype) -= size;
953 SPEC_STAK (sym->etype) = sym->stack = (xsPtr + 1);
957 /* if the debug option is set then output the
958 symbols to the map file */
961 for (sym = setFirstItem (istack->syms); sym;
962 sym = setNextItem (istack->syms))
963 cdbSymbol (sym, cdbFile, FALSE, FALSE);
965 for (sym = setFirstItem (xstack->syms); sym;
966 sym = setNextItem (xstack->syms))
967 cdbSymbol (sym, cdbFile, FALSE, FALSE);
971 /*-----------------------------------------------------------------*/
972 /* printAllocInfoSeg- print the allocation for a given section */
973 /*-----------------------------------------------------------------*/
975 printAllocInfoSeg (memmap * map, symbol * func, FILE * of)
984 for (sym = setFirstItem (map->syms); sym;
985 sym = setNextItem (map->syms))
990 if (sym->localof != func)
992 fprintf (of, ";%-25s Allocated to ", sym->name);
994 /* if assigned to registers */
995 if (!sym->allocreq && sym->reqv)
998 sym = OP_SYMBOL (sym->reqv);
999 fprintf (of, "registers ");
1000 for (i = 0; i < 4 && sym->regs[i]; i++)
1001 fprintf (of, "%s ", port->getRegName (sym->regs[i]));
1009 fprintf (of, "stack - offset %d\n", sym->stack);
1013 /* otherwise give rname */
1014 fprintf (of, "in memory with name '%s'\n", sym->rname);
1018 /*-----------------------------------------------------------------*/
1019 /* canOverlayLocals - returns true if the local variables can overlayed */
1020 /*-----------------------------------------------------------------*/
1022 canOverlayLocals (eBBlock ** ebbs, int count)
1025 /* if staticAuto is in effect or the current function
1026 being compiled is reentrant or the overlay segment
1027 is empty or no overlay option is in effect then */
1028 if (options.noOverlay ||
1029 options.stackAuto ||
1031 (IFFUNC_ISREENT (currFunc->type) ||
1032 FUNC_ISISR (currFunc->type))) ||
1033 elementsInSet (overlay->syms) == 0)
1037 /* if this is a forces overlay */
1038 if (IFFUNC_ISOVERLAY(currFunc->type)) return TRUE;
1040 /* otherwise do thru the blocks and see if there
1041 any function calls if found then return false */
1042 for (i = 0; i < count; i++)
1046 for (ic = ebbs[i]->sch; ic; ic = ic->next)
1048 if (ic->op == CALL) {
1049 sym_link *ftype = operandType(IC_LEFT(ic));
1050 /* builtins only can use overlays */
1051 if (!IFFUNC_ISBUILTIN(ftype)) return FALSE;
1052 } else if (ic->op == PCALL) return FALSE;
1056 /* no function calls found return TRUE */
1060 /*-----------------------------------------------------------------*/
1061 /* doOverlays - move the overlay segment to appropriate location */
1062 /*-----------------------------------------------------------------*/
1064 doOverlays (eBBlock ** ebbs, int count)
1066 /* check if the parameters and local variables
1067 of this function can be put in the overlay segment
1068 This check is essentially to see if the function
1069 calls any other functions if yes then we cannot
1071 if (canOverlayLocals (ebbs, count))
1072 /* if we can then put the parameters &
1073 local variables in the overlay set */
1076 /* otherwise put them into data where
1081 /*-----------------------------------------------------------------*/
1082 /* printAllocInfo - prints allocation information for a function */
1083 /*-----------------------------------------------------------------*/
1085 printAllocInfo (symbol * func, FILE * of)
1090 /* must be called after register allocation is complete */
1091 fprintf (of, ";------------------------------------------------------------\n");
1092 fprintf (of, ";Allocation info for local variables in function '%s'\n", func->name);
1093 fprintf (of, ";------------------------------------------------------------\n");
1095 printAllocInfoSeg (xstack, func, of);
1096 printAllocInfoSeg (istack, func, of);
1097 printAllocInfoSeg (code, func, of);
1098 printAllocInfoSeg (data, func, of);
1099 printAllocInfoSeg (xdata, func, of);
1100 printAllocInfoSeg (idata, func, of);
1101 printAllocInfoSeg (sfr, func, of);
1102 printAllocInfoSeg (sfrbit, func, of);