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 *pdata = NULL; /* paged external data */
13 memmap *xdata = NULL; /* external data */
14 memmap *xidata = NULL; /* the initialized xdata */
15 memmap *xinit = NULL; /* the initializers for xidata */
16 memmap *idata = NULL; /* internal data upto 256 */
17 memmap *bit = NULL; /* bit addressable space */
18 memmap *statsg = NULL; /* the constant data segment */
19 memmap *sfr = NULL; /* register space */
20 memmap *reg = NULL; /* register space */
21 memmap *sfrbit = NULL; /* sfr bit space */
22 memmap *generic = NULL; /* is a generic pointer */
23 memmap *overlay = NULL; /* overlay segment */
24 memmap *eeprom = NULL; /* eeprom location */
25 memmap *home = NULL; /* Unswitchable code bank */
27 /* this is a set of sets each set containing
28 symbols in a single overlay */
29 set *ovrSetSets = NULL;
32 int fatalError = 0; /* fatal error flag */
34 /*-----------------------------------------------------------------*/
35 /* allocMap - allocates a memory map */
36 /*-----------------------------------------------------------------*/
38 allocMap (char rspace, /* sfr space */
39 char farmap, /* far or near segment */
40 char paged, /* can this segment be paged */
41 char direct, /* directly addressable */
42 char bitaddr, /* bit addressable space */
43 char codemap, /* this is code space */
44 unsigned sloc, /* starting location */
45 const char *name, /* 2 character name */
46 char dbName, /* debug name */
47 int ptrType /* pointer type for this space */
52 if (!(map = Safe_alloc (sizeof (memmap))))
54 werror (E_OUT_OF_MEM, __FILE__, sizeof (memmap));
58 memset (map, ZERO, sizeof (memmap));
64 map->codesp = codemap;
68 map->ptrType = ptrType;
69 if (!(map->oFile = tempfile ()))
71 werror (E_TMPFILE_FAILED);
74 addSetHead (&tmpfileSet, map->oFile);
79 /*-----------------------------------------------------------------*/
80 /* initMem - allocates and initializes all the segments */
81 /*-----------------------------------------------------------------*/
85 /* allocate all the segments */
86 /* xternal stack segment ;
94 POINTER-TYPE - FPOINTER
96 xstack = allocMap (0, 1, 1, 0, 0, 0, options.xstack_loc, XSTACK_NAME, 'A', PPOINTER);
98 /* internal stack segment ;
106 POINTER-TYPE - POINTER
109 istack = allocMap (0, 0, 0, 0, 0, 0, options.stack_loc,
110 ISTACK_NAME, 'B', POINTER);
123 POINTER-TYPE - CPOINTER
125 code = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER);
135 POINTER-TYPE - CPOINTER
137 home = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER);
139 /* Static segment (code for variables );
147 POINTER-TYPE - CPOINTER
149 statsg = allocMap (0, 1, 0, 0, 0, 1, 0, STATIC_NAME, 'D', CPOINTER);
151 /* Data segment - internal storage segment ;
159 POINTER-TYPE - POINTER
161 data = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
163 /* overlay segment - same as internal storage segment ;
171 POINTER-TYPE - POINTER
174 overlay = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
179 /* Xternal paged segment ;
187 POINTER-TYPE - PPOINTER
190 pdata = allocMap (0, 0, 1, 0, 0, 0, options.xstack_loc, PDATA_NAME, 'P', PPOINTER);
195 /* Xternal Data segment -
203 POINTER-TYPE - FPOINTER
205 xdata = allocMap (0, 1, 0, 0, 0, 0, options.xdata_loc, XDATA_NAME, 'F', FPOINTER);
206 xidata = allocMap (0, 1, 0, 0, 0, 0, 0, XIDATA_NAME, 'F', FPOINTER);
207 xinit = allocMap (0, 1, 0, 0, 0, 1, 0, XINIT_NAME, 'C', CPOINTER);
209 /* Indirectly addressed internal data segment
217 POINTER-TYPE - IPOINTER
220 idata = allocMap (0, 0, 0, 0, 0, 0, options.idata_loc,
221 IDATA_NAME, 'G', IPOINTER);
234 POINTER-TYPE - _NONE_
236 bit = allocMap (0, 0, 0, 1, 1, 0, 0, BIT_NAME, 'H', 0);
238 /* Special function register space :-
246 POINTER-TYPE - _NONE_
248 sfr = allocMap (1, 0, 0, 1, 0, 0, 0, REG_NAME, 'I', 0);
258 POINTER-TYPE - _NONE_
260 reg = allocMap (1, 0, 0, 0, 0, 0, 0, REG_NAME, ' ', 0);
270 POINTER-TYPE - _NONE_
272 sfrbit = allocMap (1, 0, 0, 1, 1, 0, 0, REG_NAME, 'J', 0);
282 POINTER-TYPE - EEPPOINTER
284 eeprom = allocMap (0, 1, 0, 0, 0, 0, 0, REG_NAME, 'K', EEPPOINTER);
286 /* the unknown map */
287 generic = allocMap (1, 0, 0, 1, 1, 0, 0, REG_NAME, ' ', GPOINTER);
291 /*-----------------------------------------------------------------*/
292 /* allocIntoSeg - puts a symbol into a memory segment */
293 /*-----------------------------------------------------------------*/
295 allocIntoSeg (symbol * sym)
297 memmap *segment = SPEC_OCLS (sym->etype);
298 addSet (&segment->syms, sym);
299 if (segment == pdata)
303 /*-----------------------------------------------------------------*/
304 /* deleteFromSeg - deletes a symbol from segment used when a var */
305 /* first declared as "extern" then no extern */
306 /*-----------------------------------------------------------------*/
307 void deleteFromSeg(symbol *sym)
309 if (SPEC_OCLS(sym->etype)) {
310 memmap *segment = SPEC_OCLS (sym->etype);
311 deleteSetItem(&segment->syms,sym);
315 /*-----------------------------------------------------------------*/
316 /* allocDefault - assigns the output segment based on SCLASS */
317 /*-----------------------------------------------------------------*/
319 allocDefault (symbol * sym)
321 switch (SPEC_SCLS (sym->etype))
324 SPEC_OCLS (sym->etype) = sfr;
327 SPEC_OCLS (sym->etype) = sfrbit;
332 /* if code change to constant */
333 SPEC_OCLS (sym->etype) = statsg;
336 // should we move this to the initialized data segment?
337 if (port->genXINIT &&
338 sym->ival && (sym->level==0) && !SPEC_ABSA(sym->etype)) {
339 SPEC_OCLS(sym->etype) = xidata;
341 SPEC_OCLS (sym->etype) = xdata;
345 SPEC_OCLS (sym->etype) = data;
348 SPEC_OCLS (sym->etype) = idata;
352 SPEC_OCLS (sym->etype) = pdata;
356 SPEC_OCLS (sym->etype) = bit;
359 SPEC_OCLS (sym->etype) = eeprom;
368 /*-----------------------------------------------------------------*/
369 /* allocGlobal - assigns the output segment to a global var */
370 /*-----------------------------------------------------------------*/
372 allocGlobal (symbol * sym)
375 /* symbol name is internal name */
376 if (!sym->level) /* local statics can come here */
377 SNPRINTF (sym->rname, sizeof(sym->rname),
378 "%s%s", port->fun_prefix, sym->name);
380 /* add it to the operandKey reset */
381 if (!isinSet (operKeyReset, sym)) {
382 addSet(&operKeyReset, sym);
385 /* if this is a literal e.g. enumerated type */
386 /* put it in the data segment & do nothing */
387 if (IS_LITERAL (sym->etype))
389 SPEC_OCLS (sym->etype) = data;
393 /* if this is a function then assign code space */
394 if (IS_FUNC (sym->type))
396 SPEC_OCLS (sym->etype) = code;
397 /* if this is an interrupt service routine
398 then put it in the interrupt service array */
399 if (FUNC_ISISR (sym->type) && !options.noiv
400 && (FUNC_INTNO (sym->type) != INTNO_UNSPEC))
402 if (interrupts[FUNC_INTNO (sym->type)])
403 werror (E_INT_DEFINED,
404 FUNC_INTNO (sym->type),
405 interrupts[FUNC_INTNO (sym->type)]->name);
407 interrupts[FUNC_INTNO (sym->type)] = sym;
409 /* automagically extend the maximum interrupts */
410 if (FUNC_INTNO (sym->type) >= maxInterrupts)
411 maxInterrupts = FUNC_INTNO (sym->type) + 1;
413 /* if it is not compiler defined */
420 /* if this is a bit variable and no storage class */
421 if (IS_SPEC(sym->type) && SPEC_NOUN (sym->type) == V_BIT)
422 /*&& SPEC_SCLS (sym->etype) == S_BIT*/
424 SPEC_OCLS (sym->type) = bit;
429 if(!TARGET_IS_PIC16 || (TARGET_IS_PIC16 && sym->level))
430 /* register storage class ignored changed to FIXED */
431 if (SPEC_SCLS (sym->etype) == S_REGISTER)
432 SPEC_SCLS (sym->etype) = S_FIXED;
434 /* if it is fixed, then allocate depending on the */
435 /* current memory model, same for automatics */
436 if (SPEC_SCLS (sym->etype) == S_FIXED ||
437 (TARGET_IS_PIC16 && (SPEC_SCLS (sym->etype) == S_REGISTER) && (sym->level==0)) ||
438 SPEC_SCLS (sym->etype) == S_AUTO) {
439 if (port->mem.default_globl_map != xdata) {
440 /* set the output class */
441 SPEC_OCLS (sym->etype) = port->mem.default_globl_map;
442 /* generate the symbol */
446 SPEC_SCLS (sym->etype) = S_XDATA;
454 /*-----------------------------------------------------------------*/
455 /* allocParms - parameters are always passed on stack */
456 /*-----------------------------------------------------------------*/
458 allocParms (value * val)
463 for (lval = val; lval; lval = lval->next, pNum++)
465 /* check the declaration */
466 checkDecl (lval->sym, 0);
468 /* if this a register parm then allocate
469 it as a local variable by adding it
470 to the first block we see in the body */
471 if (IS_REGPARM (lval->etype))
474 /* mark it as my parameter */
475 lval->sym->ismyparm = 1;
476 lval->sym->localof = currFunc;
478 /* if automatic variables r 2b stacked */
479 if (options.stackAuto || IFFUNC_ISREENT (currFunc->type))
482 lval->sym->onStack = 1;
484 /* choose which stack 2 use */
485 /* use xternal stack */
486 if (options.useXstack)
488 /* PENDING: stack direction support */
489 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = xstack;
490 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
491 xstackPtr - getSize (lval->type);
492 xstackPtr -= getSize (lval->type);
495 { /* use internal stack */
496 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = istack;
497 if (port->stack.direction > 0)
499 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
500 stackPtr - (FUNC_REGBANK (currFunc->type) ? port->stack.bank_overhead : 0) -
501 getSize (lval->type) -
502 (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0);
503 stackPtr -= getSize (lval->type);
507 /* This looks like the wrong order but it turns out OK... */
508 /* PENDING: isr, bank overhead, ... */
509 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
511 ((IFFUNC_ISBANKEDCALL (currFunc->type) && !SPEC_STAT(getSpec(currFunc->etype)))? port->stack.banked_overhead : 0) +
512 (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0) +
514 stackPtr += getSize (lval->type);
517 allocIntoSeg (lval->sym);
520 { /* allocate them in the automatic space */
521 /* generate a unique name */
522 SNPRINTF (lval->sym->rname, sizeof(lval->sym->rname),
523 "%s%s_PARM_%d", port->fun_prefix, currFunc->name, pNum);
524 strncpyz (lval->name, lval->sym->rname, sizeof(lval->name));
526 /* if declared in specific storage */
527 if (allocDefault (lval->sym))
529 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype);
533 /* otherwise depending on the memory model */
534 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
535 port->mem.default_local_map;
536 if (options.model == MODEL_SMALL)
538 /* note here that we put it into the overlay segment
539 first, we will remove it from the overlay segment
540 after the overlay determination has been done */
541 if (!options.noOverlay)
543 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
547 else if (options.model == MODEL_MEDIUM)
549 SPEC_SCLS (lval->etype) = S_PDATA;
553 SPEC_SCLS (lval->etype) = S_XDATA;
555 allocIntoSeg (lval->sym);
561 /*-----------------------------------------------------------------*/
562 /* deallocParms - parameters are always passed on stack */
563 /*-----------------------------------------------------------------*/
565 deallocParms (value * val)
569 for (lval = val; lval; lval = lval->next)
571 /* unmark is myparm */
572 lval->sym->ismyparm = 0;
574 /* delete it from the symbol table */
575 deleteSym (SymbolTab, lval->sym, lval->sym->name);
577 if (!lval->sym->isref)
579 lval->sym->allocreq = 0;
580 werror (W_NO_REFERENCE,
581 currFunc ? currFunc->name : "(unknown)",
582 "function argument", lval->sym->name);
585 /* move the rname if any to the name for both val & sym */
586 /* and leave a copy of it in the symbol table */
587 if (lval->sym->rname[0])
589 char buffer[SDCC_NAME_MAX];
590 strncpyz (buffer, lval->sym->rname, sizeof(buffer));
591 lval->sym = copySymbol (lval->sym);
592 strncpyz (lval->sym->rname, buffer, sizeof(lval->sym->rname));
593 strncpyz (lval->sym->name, buffer, sizeof(lval->sym->name));
594 strncpyz (lval->name, buffer, sizeof(lval->name));
595 addSym (SymbolTab, lval->sym, lval->sym->name,
596 lval->sym->level, lval->sym->block, 1);
597 lval->sym->_isparm = 1;
598 if (!isinSet (operKeyReset, lval->sym))
600 addSet(&operKeyReset, lval->sym);
607 /*-----------------------------------------------------------------*/
608 /* allocLocal - allocate local variables */
609 /*-----------------------------------------------------------------*/
611 allocLocal (symbol * sym)
613 /* generate an unique name */
614 SNPRINTF (sym->rname, sizeof(sym->rname),
617 currFunc->name, sym->name, sym->level, sym->block);
620 sym->localof = currFunc;
622 /* if this is a static variable */
623 if (IS_STATIC (sym->etype))
630 /* if volatile then */
631 if (IS_VOLATILE (sym->etype))
634 /* this is automatic */
636 /* if it's to be placed on the stack */
637 if (options.stackAuto || reentrant) {
639 if (options.useXstack) {
640 /* PENDING: stack direction for xstack */
641 SPEC_OCLS (sym->etype) = xstack;
642 SPEC_STAK (sym->etype) = sym->stack = (xstackPtr + 1);
643 xstackPtr += getSize (sym->type);
645 SPEC_OCLS (sym->etype) = istack;
646 if (port->stack.direction > 0) {
647 SPEC_STAK (sym->etype) = sym->stack = (stackPtr + 1);
648 stackPtr += getSize (sym->type);
650 stackPtr -= getSize (sym->type);
651 SPEC_STAK (sym->etype) = sym->stack = stackPtr;
658 /* else depending on the storage class specified */
660 /* if this is a function then assign code space */
661 if (IS_FUNC (sym->type))
663 SPEC_OCLS (sym->etype) = code;
667 /* if this is a bit variable and no storage class */
668 if (IS_SPEC(sym->type) && SPEC_NOUN (sym->type) == V_BIT)
670 SPEC_SCLS (sym->type) = S_BIT;
671 SPEC_OCLS (sym->type) = bit;
676 if ((SPEC_SCLS (sym->etype) == S_DATA) || (SPEC_SCLS (sym->etype) == S_REGISTER))
678 SPEC_OCLS (sym->etype) = (options.noOverlay ? data : overlay);
683 if (allocDefault (sym))
688 /* again note that we have put it into the overlay segment
689 will remove and put into the 'data' segment if required after
690 overlay analysis has been done */
691 if (options.model == MODEL_SMALL) {
692 SPEC_OCLS (sym->etype) =
693 (options.noOverlay ? port->mem.default_local_map : overlay);
695 SPEC_OCLS (sym->etype) = port->mem.default_local_map;
700 /*-----------------------------------------------------------------*/
701 /* deallocLocal - deallocates the local variables */
702 /*-----------------------------------------------------------------*/
704 deallocLocal (symbol * csym)
708 for (sym = csym; sym; sym = sym->next)
713 /* if it is on the stack */
716 if (options.useXstack)
717 xstackPtr -= getSize (sym->type);
719 stackPtr -= getSize (sym->type);
721 /* if not used give a warning */
722 if (!sym->isref && !IS_STATIC (sym->etype))
723 werror (W_NO_REFERENCE,
724 currFunc ? currFunc->name : "(unknown)",
725 "local variable", sym->name);
726 /* now delete it from the symbol table */
727 deleteSym (SymbolTab, sym, sym->name);
731 /*-----------------------------------------------------------------*/
732 /* overlay2data - moves declarations from the overlay seg to data */
733 /*-----------------------------------------------------------------*/
739 for (sym = setFirstItem (overlay->syms); sym;
740 sym = setNextItem (overlay->syms))
743 SPEC_OCLS (sym->etype) = data;
747 setToNull ((void *) &overlay->syms);
751 /*-----------------------------------------------------------------*/
752 /* overlay2Set - will add all symbols from the overlay segment to */
753 /* the set of sets containing the overlable symbols */
754 /*-----------------------------------------------------------------*/
761 for (sym = setFirstItem (overlay->syms); sym;
762 sym = setNextItem (overlay->syms))
768 setToNull ((void *) &overlay->syms);
769 addSet (&ovrSetSets, oset);
773 /*-----------------------------------------------------------------*/
774 /* allocVariables - creates decl & assign storage class for a v */
775 /*-----------------------------------------------------------------*/
777 allocVariables (symbol * symChain)
784 /* go thru the symbol chain */
785 for (sym = symChain; sym; sym = sym->next)
788 /* if this is a typedef then add it */
789 /* to the typedef table */
790 if (IS_TYPEDEF (sym->etype))
792 /* check if the typedef already exists */
793 csym = findSym (TypedefTab, NULL, sym->name);
794 if (csym && csym->level == sym->level)
795 werror (E_DUPLICATE_TYPEDEF, sym->name);
797 SPEC_EXTR (sym->etype) = 0;
798 addSym (TypedefTab, sym, sym->name, sym->level, sym->block, 0);
799 continue; /* go to the next one */
801 /* make sure it already exist */
802 csym = findSymWithLevel (SymbolTab, sym);
803 if (!csym || (csym && csym->level != sym->level))
806 /* check the declaration */
809 /* if this is a function or a pointer to function */
810 /* then args processing */
811 if (funcInChain (csym->type))
813 processFuncArgs (csym);
815 /* if register bank specified then update maxRegBank */
816 if (maxRegBank < FUNC_REGBANK (csym->type))
817 maxRegBank = FUNC_REGBANK (csym->type);
818 /*JCF: Mark the register bank as used*/
819 RegBankUsed[FUNC_REGBANK(csym->type)]=1;
822 /* if this is a extern variable then change the */
823 /* level to zero temporarily */
824 if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
826 saveLevel = csym->level;
830 /* if this is a literal then it is an enumerated */
831 /* type so need not allocate it space for it */
832 if (IS_LITERAL (sym->etype))
835 /* generate the actual declaration */
840 stack += getSize (csym->type);
845 /* restore the level */
846 if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
847 csym->level = saveLevel;
853 /*-----------------------------------------------------------------*/
854 /* redoStackOffsets :- will reassign the values for stack offsets */
855 /*-----------------------------------------------------------------*/
857 redoStackOffsets (void)
863 /* after register allocation is complete we know
864 which variables will need to be assigned space
865 on the stack. We will eliminate those variables
866 which do not have the allocReq flag thus reducing
868 for (sym = setFirstItem (istack->syms); sym;
869 sym = setNextItem (istack->syms))
872 int size = getSize (sym->type);
873 /* nothing to do with parameters so continue */
874 if ((sym->_isparm && !IS_REGPARM (sym->etype)))
877 if (IS_AGGREGATE (sym->type))
879 if (port->stack.direction > 0)
881 SPEC_STAK (sym->etype) = sym->stack = (sPtr + 1);
887 SPEC_STAK (sym->etype) = sym->stack = sPtr;
892 /* if allocation not required then subtract
893 size from overall stack size & continue */
896 currFunc->stack -= size;
897 SPEC_STAK (currFunc->etype) -= size;
901 if (port->stack.direction > 0)
903 SPEC_STAK (sym->etype) = sym->stack = (sPtr + 1);
909 SPEC_STAK (sym->etype) = sym->stack = sPtr;
913 /* do the same for the external stack */
915 for (sym = setFirstItem (xstack->syms); sym;
916 sym = setNextItem (xstack->syms))
919 int size = getSize (sym->type);
920 /* nothing to do with parameters so continue */
921 if ((sym->_isparm && !IS_REGPARM (sym->etype)))
924 if (IS_AGGREGATE (sym->type))
926 SPEC_STAK (sym->etype) = sym->stack = (xsPtr + 1);
931 /* if allocation not required then subtract
932 size from overall stack size & continue */
935 currFunc->xstack -= size;
936 SPEC_STAK (currFunc->etype) -= size;
940 SPEC_STAK (sym->etype) = sym->stack = (xsPtr + 1);
946 /*-----------------------------------------------------------------*/
947 /* printAllocInfoSeg- print the allocation for a given section */
948 /*-----------------------------------------------------------------*/
950 printAllocInfoSeg (memmap * map, symbol * func, FILE * of)
959 for (sym = setFirstItem (map->syms); sym;
960 sym = setNextItem (map->syms))
965 if (sym->localof != func)
968 fprintf (of, ";%-25s Allocated ", sym->name);
970 /* if assigned to registers */
971 if (!sym->allocreq && sym->reqv)
975 sym = OP_SYMBOL (sym->reqv);
976 if (!sym->isspilt || sym->remat)
978 fprintf (of, "to registers ");
979 for (i = 0; i < 4 && sym->regs[i]; i++)
980 fprintf (of, "%s ", port->getRegName (sym->regs[i]));
986 sym = sym->usl.spillLoc;
993 fprintf (of, "to stack - offset %d\n", sym->stack);
997 /* otherwise give rname */
998 fprintf (of, "with name '%s'\n", sym->rname);
1002 /*-----------------------------------------------------------------*/
1003 /* canOverlayLocals - returns true if the local variables can overlayed */
1004 /*-----------------------------------------------------------------*/
1006 canOverlayLocals (eBBlock ** ebbs, int count)
1009 /* if staticAuto is in effect or the current function
1010 being compiled is reentrant or the overlay segment
1011 is empty or no overlay option is in effect then */
1012 if (options.noOverlay ||
1013 options.stackAuto ||
1015 (IFFUNC_ISREENT (currFunc->type) ||
1016 FUNC_ISISR (currFunc->type))) ||
1017 elementsInSet (overlay->syms) == 0)
1021 /* if this is a forces overlay */
1022 if (IFFUNC_ISOVERLAY(currFunc->type)) return TRUE;
1024 /* otherwise do thru the blocks and see if there
1025 any function calls if found then return false */
1026 for (i = 0; i < count; i++)
1030 for (ic = ebbs[i]->sch; ic; ic = ic->next)
1032 if (ic->op == CALL) {
1033 sym_link *ftype = operandType(IC_LEFT(ic));
1034 /* builtins only can use overlays */
1035 if (!IFFUNC_ISBUILTIN(ftype)) return FALSE;
1036 } else if (ic->op == PCALL) return FALSE;
1040 /* no function calls found return TRUE */
1044 /*-----------------------------------------------------------------*/
1045 /* doOverlays - move the overlay segment to appropriate location */
1046 /*-----------------------------------------------------------------*/
1048 doOverlays (eBBlock ** ebbs, int count)
1054 /* check if the parameters and local variables
1055 of this function can be put in the overlay segment
1056 This check is essentially to see if the function
1057 calls any other functions if yes then we cannot
1059 if (canOverlayLocals (ebbs, count))
1060 /* if we can then put the parameters &
1061 local variables in the overlay set */
1064 /* otherwise put them into data where
1069 /*-----------------------------------------------------------------*/
1070 /* printAllocInfo - prints allocation information for a function */
1071 /*-----------------------------------------------------------------*/
1073 printAllocInfo (symbol * func, FILE * of)
1081 /* must be called after register allocation is complete */
1082 fprintf (of, ";------------------------------------------------------------\n");
1083 fprintf (of, ";Allocation info for local variables in function '%s'\n", func->name);
1084 fprintf (of, ";------------------------------------------------------------\n");
1086 printAllocInfoSeg (xstack, func, of);
1087 printAllocInfoSeg (istack, func, of);
1088 printAllocInfoSeg (code, func, of);
1089 printAllocInfoSeg (data, func, of);
1090 printAllocInfoSeg (xdata, func, of);
1091 printAllocInfoSeg (idata, func, of);
1092 printAllocInfoSeg (sfr, func, of);
1093 printAllocInfoSeg (sfrbit, func, of);
1097 set *tempOverlaySyms = overlay->syms;
1099 /* search the set of overlay sets for local variables/parameters */
1100 for (ovrset = setFirstItem (ovrSetSets); ovrset;
1101 ovrset = setNextItem (ovrSetSets))
1103 overlay->syms = ovrset;
1104 printAllocInfoSeg (overlay, func, of);
1106 overlay->syms = tempOverlaySyms;
1109 fprintf (of, ";------------------------------------------------------------\n");