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
108 istack = allocMap (0, 0, 0, 0, 0, 0, options.stack_loc,
109 ISTACK_NAME, 'B', POINTER);
122 POINTER-TYPE - CPOINTER
124 code = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER);
134 POINTER-TYPE - CPOINTER
136 home = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER);
138 /* Static segment (code for variables );
146 POINTER-TYPE - CPOINTER
148 statsg = allocMap (0, 1, 0, 0, 0, 1, 0, STATIC_NAME, 'D', CPOINTER);
150 /* Data segment - internal storage segment ;
158 POINTER-TYPE - POINTER
160 data = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
162 /* overlay segment - same as internal storage segment ;
170 POINTER-TYPE - POINTER
173 overlay = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
178 /* Xternal Data segment -
186 POINTER-TYPE - FPOINTER
188 xdata = allocMap (0, 1, 0, 0, 0, 0, options.xdata_loc, XDATA_NAME, 'F', FPOINTER);
189 xidata = allocMap (0, 1, 0, 0, 0, 0, 0, XIDATA_NAME, 'F', FPOINTER);
190 xinit = allocMap (0, 1, 0, 0, 0, 1, 0, XINIT_NAME, 'C', CPOINTER);
192 /* Inderectly addressed internal data segment
200 POINTER-TYPE - IPOINTER
203 idata = allocMap (0, 0, 0, 0, 0, 0, options.idata_loc,
204 IDATA_NAME, 'G', IPOINTER);
209 /* Static segment (code for variables );
217 POINTER-TYPE - _NONE_
219 bit = allocMap (0, 0, 0, 1, 1, 0, 0, BIT_NAME, 'H', 0);
221 /* Special function register space :-
229 POINTER-TYPE - _NONE_
231 sfr = allocMap (1, 0, 0, 1, 0, 0, 0, REG_NAME, 'I', 0);
241 POINTER-TYPE - _NONE_
243 reg = allocMap (1, 0, 0, 0, 0, 0, 0, REG_NAME, ' ', 0);
253 POINTER-TYPE - _NONE_
255 sfrbit = allocMap (1, 0, 0, 1, 1, 0, 0, REG_NAME, 'J', 0);
265 POINTER-TYPE - EEPPOINTER
267 eeprom = allocMap (0, 1, 0, 0, 0, 0, 0, REG_NAME, 'K', EEPPOINTER);
269 /* the unknown map */
270 generic = allocMap (1, 0, 0, 1, 1, 0, 0, REG_NAME, ' ', GPOINTER);
274 /*-----------------------------------------------------------------*/
275 /* allocIntoSeg - puts a symbol into a memory segment */
276 /*-----------------------------------------------------------------*/
278 allocIntoSeg (symbol * sym)
280 memmap *segment = SPEC_OCLS (sym->etype);
281 addSet (&segment->syms, sym);
284 /*-----------------------------------------------------------------*/
285 /* deleteFromSeg - deletes a symbol from segment used when a var */
286 /* firest declared as "extern" then no extern */
287 /*-----------------------------------------------------------------*/
288 void deleteFromSeg(symbol *sym)
290 if (SPEC_OCLS(sym->etype)) {
291 memmap *segment = SPEC_OCLS (sym->etype);
292 deleteSetItem(&segment->syms,sym);
297 /*-----------------------------------------------------------------*/
298 /* allocGlobal - assigns the output segment to a global var */
299 /*-----------------------------------------------------------------*/
301 allocGlobal (symbol * sym)
304 /* symbol name is internal name */
305 if (!sym->level) /* local statics can come here */
306 SNPRINTF (sym->rname, sizeof(sym->rname),
307 "%s%s", port->fun_prefix, sym->name);
309 /* add it to the operandKey reset */
310 if (!isinSet (operKeyReset, sym)) {
311 addSet(&operKeyReset, sym);
314 /* if this is a literal e.g. enumerated type */
315 /* put it in the data segment & do nothing */
316 if (IS_LITERAL (sym->etype))
318 SPEC_OCLS (sym->etype) = data;
322 /* if this is a function then assign code space */
323 if (IS_FUNC (sym->type))
325 SPEC_OCLS (sym->etype) = code;
326 /* if this is an interrupt service routine
327 then put it in the interrupt service array */
328 if (FUNC_ISISR (sym->type) && !options.noiv)
331 if (interrupts[FUNC_INTNO (sym->type)])
332 werror (E_INT_DEFINED,
333 FUNC_INTNO (sym->type),
334 interrupts[FUNC_INTNO (sym->type)]->name);
336 interrupts[FUNC_INTNO (sym->type)] = sym;
338 /* automagically extend the maximum interrupts */
339 if (FUNC_INTNO (sym->type) >= maxInterrupts)
340 maxInterrupts = FUNC_INTNO (sym->type) + 1;
342 /* if it is not compiler defined */
349 /* if this is a SFR or SBIT */
350 if (SPEC_SCLS (sym->etype) == S_SFR ||
351 SPEC_SCLS (sym->etype) == S_SBIT)
354 SPEC_OCLS (sym->etype) =
355 (SPEC_SCLS (sym->etype) == S_SFR ? sfr : sfrbit);
361 /* if this is a bit variable and no storage class */
362 if (SPEC_NOUN (sym->etype) == V_BIT
363 && SPEC_SCLS (sym->etype) == S_BIT)
365 SPEC_OCLS (sym->etype) = bit;
370 /* if bit storage class */
371 if (SPEC_SCLS (sym->etype) == S_SBIT)
373 SPEC_OCLS (sym->etype) = bit;
378 /* register storage class ignored changed to FIXED */
379 if (SPEC_SCLS (sym->etype) == S_REGISTER)
380 SPEC_SCLS (sym->etype) = S_FIXED;
382 /* if data specified then */
383 if (SPEC_SCLS (sym->etype) == S_DATA)
385 /* set the output class */
386 SPEC_OCLS (sym->etype) = data;
387 /* generate the symbol */
392 /* if it is fixed, then allocate depending on the */
393 /* current memory model, same for automatics */
394 if (SPEC_SCLS (sym->etype) == S_FIXED ||
395 SPEC_SCLS (sym->etype) == S_AUTO) {
396 if (port->mem.default_globl_map != xdata) {
397 /* set the output class */
398 SPEC_OCLS (sym->etype) = port->mem.default_globl_map;
399 /* generate the symbol */
403 SPEC_SCLS (sym->etype) = S_XDATA;
407 /* if code change to constant */
408 if (SPEC_SCLS (sym->etype) == S_CODE) {
409 SPEC_OCLS (sym->etype) = statsg;
414 if (SPEC_SCLS (sym->etype) == S_XDATA)
416 // should we move this to the initialized data segment?
417 if (port->genXINIT &&
418 sym->ival && (sym->level==0) && !SPEC_ABSA(sym->etype)) {
419 SPEC_OCLS(sym->etype)=xidata;
421 SPEC_OCLS (sym->etype) = xdata;
427 if (SPEC_SCLS (sym->etype) == S_IDATA)
429 SPEC_OCLS (sym->etype) = idata;
435 if (SPEC_SCLS (sym->etype) == S_EEPROM)
437 SPEC_OCLS (sym->etype) = eeprom;
445 /*-----------------------------------------------------------------*/
446 /* allocParms - parameters are always passed on stack */
447 /*-----------------------------------------------------------------*/
449 allocParms (value * val)
454 for (lval = val; lval; lval = lval->next, pNum++)
457 /* check the declaration */
458 checkDecl (lval->sym, 0);
460 /* if this a register parm then allocate
461 it as a local variable by adding it
462 to the first block we see in the body */
463 if (IS_REGPARM (lval->etype))
466 /* mark it as my parameter */
467 lval->sym->ismyparm = 1;
468 lval->sym->localof = currFunc;
471 /* if automatic variables r 2b stacked */
472 if (options.stackAuto || IFFUNC_ISREENT (currFunc->type))
476 lval->sym->onStack = 1;
478 /* choose which stack 2 use */
479 /* use xternal stack */
480 if (options.useXstack)
482 /* PENDING: stack direction support */
483 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = xstack;
484 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
485 xstackPtr - getSize (lval->type);
486 xstackPtr -= getSize (lval->type);
489 { /* use internal stack */
490 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = istack;
491 if (port->stack.direction > 0)
493 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
494 stackPtr - (FUNC_REGBANK (currFunc->type) ? port->stack.bank_overhead : 0) -
495 getSize (lval->type) -
496 (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0);
497 stackPtr -= getSize (lval->type);
501 /* This looks like the wrong order but it turns out OK... */
502 /* PENDING: isr, bank overhead, ... */
503 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
505 ((IFFUNC_ISBANKEDCALL (currFunc->type) && !SPEC_STAT(getSpec(currFunc->etype)))? port->stack.banked_overhead : 0) +
506 (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0) +
508 stackPtr += getSize (lval->type);
511 allocIntoSeg (lval->sym);
514 { /* allocate them in the automatic space */
515 /* generate a unique name */
516 SNPRINTF (lval->sym->rname, sizeof(lval->sym->rname),
517 "%s%s_PARM_%d", port->fun_prefix, currFunc->name, pNum);
518 strncpyz (lval->name, lval->sym->rname, sizeof(lval->name));
520 /* if declared in external storage */
521 if (SPEC_SCLS (lval->etype) == S_XDATA)
522 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = xdata;
524 /* other wise depending on the memory model
525 note here that we put it into the overlay segment
526 first, we will remove it from the overlay segment
527 after the overlay determination has been done */
528 if (options.model == MODEL_SMALL)
530 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
531 (options.noOverlay ? port->mem.default_local_map
536 SPEC_SCLS (lval->etype) = S_XDATA;
537 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = xdata;
539 allocIntoSeg (lval->sym);
546 /*-----------------------------------------------------------------*/
547 /* deallocParms - parameters are always passed on stack */
548 /*-----------------------------------------------------------------*/
550 deallocParms (value * val)
554 for (lval = val; lval; lval = lval->next)
557 /* unmark is myparm */
558 lval->sym->ismyparm = 0;
560 /* delete it from the symbol table */
561 deleteSym (SymbolTab, lval->sym, lval->sym->name);
563 if (!lval->sym->isref)
565 lval->sym->allocreq = 0;
566 werror (W_NO_REFERENCE, currFunc->name,
567 "function argument", lval->sym->name);
570 /* move the rname if any to the name for both val & sym */
571 /* and leave a copy of it in the symbol table */
572 if (lval->sym->rname[0])
574 char buffer[SDCC_NAME_MAX];
575 strncpyz (buffer, lval->sym->rname, sizeof(buffer));
576 lval->sym = copySymbol (lval->sym);
577 strncpyz (lval->sym->rname, buffer, sizeof(lval->sym->rname));
578 strncpyz (lval->sym->name, buffer, sizeof(lval->sym->name));
579 strncpyz (lval->name, buffer, sizeof(lval->name));
580 addSym (SymbolTab, lval->sym, lval->sym->name,
581 lval->sym->level, lval->sym->block, 1);
582 lval->sym->_isparm = 1;
583 if (!isinSet (operKeyReset, lval->sym)) {
584 addSet(&operKeyReset, lval->sym);
593 /*-----------------------------------------------------------------*/
594 /* allocLocal - allocate local variables */
595 /*-----------------------------------------------------------------*/
597 allocLocal (symbol * sym)
600 /* generate an unique name */
601 SNPRINTF (sym->rname, sizeof(sym->rname),
604 currFunc->name, sym->name, sym->level, sym->block);
607 sym->localof = currFunc;
609 /* if this is a static variable */
610 if (IS_STATIC (sym->etype))
617 /* if volatile then */
618 if (IS_VOLATILE (sym->etype))
621 /* this is automatic */
623 /* if it to be placed on the stack */
624 if (options.stackAuto || reentrant) {
626 if (options.useXstack) {
627 /* PENDING: stack direction for xstack */
628 SPEC_OCLS (sym->etype) = xstack;
629 SPEC_STAK (sym->etype) = sym->stack = (xstackPtr + 1);
630 xstackPtr += getSize (sym->type);
632 SPEC_OCLS (sym->etype) = istack;
633 if (port->stack.direction > 0) {
634 SPEC_STAK (sym->etype) = sym->stack = (stackPtr + 1);
635 stackPtr += getSize (sym->type);
637 stackPtr -= getSize (sym->type);
638 SPEC_STAK (sym->etype) = sym->stack = stackPtr;
645 /* else depending on the storage class specified */
646 if (SPEC_SCLS (sym->etype) == S_XDATA)
648 SPEC_OCLS (sym->etype) = xdata;
653 if (SPEC_SCLS (sym->etype) == S_CODE && !sym->_isparm) {
654 SPEC_OCLS (sym->etype) = statsg;
659 if (SPEC_SCLS (sym->etype) == S_IDATA)
661 SPEC_OCLS (sym->etype) = idata;
667 /* if this is a function then assign code space */
668 if (IS_FUNC (sym->type))
670 SPEC_OCLS (sym->etype) = code;
674 /* if this is a SFR or SBIT */
675 if (SPEC_SCLS (sym->etype) == S_SFR ||
676 SPEC_SCLS (sym->etype) == S_SBIT)
678 SPEC_OCLS (sym->etype) =
679 (SPEC_SCLS (sym->etype) == S_SFR ? sfr : sfrbit);
685 /* if this is a bit variable and no storage class */
686 if (SPEC_NOUN (sym->etype) == V_BIT
687 && (SPEC_SCLS (sym->etype) == S_BIT))
689 SPEC_OCLS (sym->etype) = bit;
694 if (SPEC_SCLS (sym->etype) == S_DATA)
696 SPEC_OCLS (sym->etype) = (options.noOverlay ? data : overlay);
701 if (SPEC_SCLS (sym->etype) == S_EEPROM)
703 SPEC_OCLS (sym->etype) = eeprom;
708 /* again note that we have put it into the overlay segment
709 will remove and put into the 'data' segment if required after
710 overlay analysis has been done */
711 if (options.model == MODEL_SMALL) {
712 SPEC_OCLS (sym->etype) =
713 (options.noOverlay ? port->mem.default_local_map
716 SPEC_OCLS (sym->etype) = port->mem.default_local_map;
721 /*-----------------------------------------------------------------*/
722 /* deallocLocal - deallocates the local variables */
723 /*-----------------------------------------------------------------*/
725 deallocLocal (symbol * csym)
729 for (sym = csym; sym; sym = sym->next)
734 /* if it is on the stack */
737 if (options.useXstack)
738 xstackPtr -= getSize (sym->type);
740 stackPtr -= getSize (sym->type);
742 /* if not used give a warning */
743 if (!sym->isref && !IS_STATIC (sym->etype))
744 werror (W_NO_REFERENCE, currFunc->name,
745 "local variable", sym->name);
746 /* now delete it from the symbol table */
747 deleteSym (SymbolTab, sym, sym->name);
751 /*-----------------------------------------------------------------*/
752 /* overlay2data - moves declarations from the overlay seg to data */
753 /*-----------------------------------------------------------------*/
759 for (sym = setFirstItem (overlay->syms); sym;
760 sym = setNextItem (overlay->syms))
763 SPEC_OCLS (sym->etype) = data;
767 setToNull ((void **) &overlay->syms);
771 /*-----------------------------------------------------------------*/
772 /* overlay2Set - will add all symbols from the overlay segment to */
773 /* the set of sets containing the overlable symbols */
774 /*-----------------------------------------------------------------*/
781 for (sym = setFirstItem (overlay->syms); sym;
782 sym = setNextItem (overlay->syms))
788 setToNull ((void **) &overlay->syms);
789 addSet (&ovrSetSets, oset);
793 /*-----------------------------------------------------------------*/
794 /* allocVariables - creates decl & assign storage class for a v */
795 /*-----------------------------------------------------------------*/
797 allocVariables (symbol * symChain)
804 /* go thru the symbol chain */
805 for (sym = symChain; sym; sym = sym->next)
808 /* if this is a typedef then add it */
809 /* to the typedef table */
810 if (IS_TYPEDEF (sym->etype))
812 /* check if the typedef already exists */
813 csym = findSym (TypedefTab, NULL, sym->name);
814 if (csym && csym->level == sym->level)
815 werror (E_DUPLICATE_TYPEDEF, sym->name);
817 addSym (TypedefTab, sym, sym->name, sym->level, sym->block, 0);
818 continue; /* go to the next one */
820 /* make sure it already exist */
821 csym = findSymWithLevel (SymbolTab, sym);
822 if (!csym || (csym && csym->level != sym->level))
825 /* check the declaration */
828 /* if this is a function or a pointer to function */
829 /* then args processing */
830 if (funcInChain (csym->type))
832 processFuncArgs (csym);
834 /* if register bank specified then update maxRegBank */
835 if (maxRegBank < FUNC_REGBANK (csym->type))
836 maxRegBank = FUNC_REGBANK (csym->type);
837 /*JCF: Mark the register bank as used*/
838 RegBankUsed[FUNC_REGBANK(csym->type)]=1;
841 /* if this is a extern variable then change the */
842 /* level to zero temporarily */
843 if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
845 saveLevel = csym->level;
849 /* if this is a literal then it is an enumerated */
850 /* type so need not allocate it space for it */
851 if (IS_LITERAL (sym->etype))
854 /* generate the actual declaration */
859 stack += getSize (csym->type);
864 /* restore the level */
865 if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
866 csym->level = saveLevel;
872 /*-----------------------------------------------------------------*/
873 /* redoStackOffsets :- will reassign the values for stack offsets */
874 /*-----------------------------------------------------------------*/
876 redoStackOffsets (void)
882 /* after register allocation is complete we know
883 which variables will need to be assigned space
884 on the stack. We will eliminate those variables
885 which do not have the allocReq flag thus reducing
887 for (sym = setFirstItem (istack->syms); sym;
888 sym = setNextItem (istack->syms))
891 int size = getSize (sym->type);
892 /* nothing to do with parameters so continue */
893 if ((sym->_isparm && !IS_REGPARM (sym->etype)))
896 if (IS_AGGREGATE (sym->type))
898 if (port->stack.direction > 0)
900 SPEC_STAK (sym->etype) = sym->stack = (sPtr + 1);
906 SPEC_STAK (sym->etype) = sym->stack = sPtr;
911 /* if allocation not required then subtract
912 size from overall stack size & continue */
915 currFunc->stack -= size;
916 SPEC_STAK (currFunc->etype) -= size;
920 if (port->stack.direction > 0)
922 SPEC_STAK (sym->etype) = sym->stack = (sPtr + 1);
928 SPEC_STAK (sym->etype) = sym->stack = sPtr;
932 /* do the same for the external stack */
934 for (sym = setFirstItem (xstack->syms); sym;
935 sym = setNextItem (xstack->syms))
938 int size = getSize (sym->type);
939 /* nothing to do with parameters so continue */
940 if ((sym->_isparm && !IS_REGPARM (sym->etype)))
943 if (IS_AGGREGATE (sym->type))
945 SPEC_STAK (sym->etype) = sym->stack = (xsPtr + 1);
950 /* if allocation not required then subtract
951 size from overall stack size & continue */
954 currFunc->xstack -= size;
955 SPEC_STAK (currFunc->etype) -= size;
959 SPEC_STAK (sym->etype) = sym->stack = (xsPtr + 1);
965 /*-----------------------------------------------------------------*/
966 /* printAllocInfoSeg- print the allocation for a given section */
967 /*-----------------------------------------------------------------*/
969 printAllocInfoSeg (memmap * map, symbol * func, FILE * of)
978 for (sym = setFirstItem (map->syms); sym;
979 sym = setNextItem (map->syms))
984 if (sym->localof != func)
986 fprintf (of, ";%-25s Allocated to ", sym->name);
988 /* if assigned to registers */
989 if (!sym->allocreq && sym->reqv)
993 sym = OP_SYMBOL (sym->reqv);
994 fprintf (of, "registers ");
995 for (i = 0; i < 4 && sym->regs[i]; i++)
996 fprintf (of, "%s ", port->getRegName (sym->regs[i]));
1004 fprintf (of, "stack - offset %d\n", sym->stack);
1008 /* otherwise give rname */
1009 fprintf (of, "in memory with name '%s'\n", sym->rname);
1013 /*-----------------------------------------------------------------*/
1014 /* canOverlayLocals - returns true if the local variables can overlayed */
1015 /*-----------------------------------------------------------------*/
1017 canOverlayLocals (eBBlock ** ebbs, int count)
1020 /* if staticAuto is in effect or the current function
1021 being compiled is reentrant or the overlay segment
1022 is empty or no overlay option is in effect then */
1023 if (options.noOverlay ||
1024 options.stackAuto ||
1026 (IFFUNC_ISREENT (currFunc->type) ||
1027 FUNC_ISISR (currFunc->type))) ||
1028 elementsInSet (overlay->syms) == 0)
1032 /* if this is a forces overlay */
1033 if (IFFUNC_ISOVERLAY(currFunc->type)) return TRUE;
1035 /* otherwise do thru the blocks and see if there
1036 any function calls if found then return false */
1037 for (i = 0; i < count; i++)
1041 for (ic = ebbs[i]->sch; ic; ic = ic->next)
1043 if (ic->op == CALL) {
1044 sym_link *ftype = operandType(IC_LEFT(ic));
1045 /* builtins only can use overlays */
1046 if (!IFFUNC_ISBUILTIN(ftype)) return FALSE;
1047 } else if (ic->op == PCALL) return FALSE;
1051 /* no function calls found return TRUE */
1055 /*-----------------------------------------------------------------*/
1056 /* doOverlays - move the overlay segment to appropriate location */
1057 /*-----------------------------------------------------------------*/
1059 doOverlays (eBBlock ** ebbs, int count)
1065 /* check if the parameters and local variables
1066 of this function can be put in the overlay segment
1067 This check is essentially to see if the function
1068 calls any other functions if yes then we cannot
1070 if (canOverlayLocals (ebbs, count))
1071 /* if we can then put the parameters &
1072 local variables in the overlay set */
1075 /* otherwise put them into data where
1080 /*-----------------------------------------------------------------*/
1081 /* printAllocInfo - prints allocation information for a function */
1082 /*-----------------------------------------------------------------*/
1084 printAllocInfo (symbol * func, FILE * of)
1092 /* must be called after register allocation is complete */
1093 fprintf (of, ";------------------------------------------------------------\n");
1094 fprintf (of, ";Allocation info for local variables in function '%s'\n", func->name);
1095 fprintf (of, ";------------------------------------------------------------\n");
1097 printAllocInfoSeg (xstack, func, of);
1098 printAllocInfoSeg (istack, func, of);
1099 printAllocInfoSeg (code, func, of);
1100 printAllocInfoSeg (data, func, of);
1101 printAllocInfoSeg (xdata, func, of);
1102 printAllocInfoSeg (idata, func, of);
1103 printAllocInfoSeg (sfr, func, of);
1104 printAllocInfoSeg (sfrbit, func, of);
1105 fprintf (of, ";------------------------------------------------------------\n");