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 *c_abs = NULL; /* constant absolute data */
20 memmap *sfr = NULL; /* register space */
21 memmap *reg = NULL; /* register space */
22 memmap *sfrbit = NULL; /* sfr bit space */
23 memmap *generic = NULL; /* is a generic pointer */
24 memmap *overlay = NULL; /* overlay segment */
25 memmap *eeprom = NULL; /* eeprom location */
26 memmap *home = NULL; /* Unswitchable code bank */
28 /* this is a set of sets each set containing
29 symbols in a single overlay */
30 set *ovrSetSets = NULL;
33 int fatalError = 0; /* fatal error flag */
35 /*-----------------------------------------------------------------*/
36 /* allocMap - allocates a memory map */
37 /*-----------------------------------------------------------------*/
39 allocMap (char rspace, /* sfr space */
40 char farmap, /* far or near segment */
41 char paged, /* can this segment be paged */
42 char direct, /* directly addressable */
43 char bitaddr, /* bit addressable space */
44 char codemap, /* this is code space */
45 unsigned sloc, /* starting location */
46 const char *name, /* 2 character name */
47 char dbName, /* debug name */
48 int ptrType /* pointer type for this space */
53 if (!(map = Safe_alloc (sizeof (memmap))))
55 werror (E_OUT_OF_MEM, __FILE__, sizeof (memmap));
59 memset (map, ZERO, sizeof (memmap));
65 map->codesp = codemap;
69 map->ptrType = ptrType;
70 if (!(map->oFile = tempfile ()))
72 werror (E_TMPFILE_FAILED);
75 addSetHead (&tmpfileSet, map->oFile);
80 /*-----------------------------------------------------------------*/
81 /* initMem - allocates and initializes all the segments */
82 /*-----------------------------------------------------------------*/
86 /* allocate all the segments */
87 /* xternal stack segment ;
95 POINTER-TYPE - FPOINTER
97 xstack = allocMap (0, 1, 1, 0, 0, 0, options.xstack_loc, XSTACK_NAME, 'A', PPOINTER);
99 /* internal stack segment ;
107 POINTER-TYPE - POINTER
110 istack = allocMap (0, 0, 0, 0, 0, 0, options.stack_loc,
111 ISTACK_NAME, 'B', POINTER);
124 POINTER-TYPE - CPOINTER
126 code = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER);
136 POINTER-TYPE - CPOINTER
138 home = allocMap (0, 1, 0, 0, 0, 1, options.code_loc, CODE_NAME, 'C', CPOINTER);
140 /* Static segment (code for variables );
148 POINTER-TYPE - CPOINTER
150 statsg = allocMap (0, 1, 0, 0, 0, 1, 0, STATIC_NAME, 'D', CPOINTER);
152 /* Constant Absolute Data segment (for variables );
160 POINTER-TYPE - CPOINTER
162 c_abs = allocMap (0, 1, 0, 0, 0, 1, 0, CABS_NAME, 'D', CPOINTER);
164 /* Data segment - internal storage segment ;
172 POINTER-TYPE - POINTER
174 data = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
176 /* overlay segment - same as internal storage segment ;
184 POINTER-TYPE - POINTER
187 overlay = allocMap (0, 0, 0, 1, 0, 0, options.data_loc, DATA_NAME, 'E', POINTER);
192 /* Xternal paged segment ;
200 POINTER-TYPE - PPOINTER
203 pdata = allocMap (0, 0, 1, 0, 0, 0, options.xstack_loc, PDATA_NAME, 'P', PPOINTER);
208 /* Xternal Data segment -
216 POINTER-TYPE - FPOINTER
218 xdata = allocMap (0, 1, 0, 0, 0, 0, options.xdata_loc, XDATA_NAME, 'F', FPOINTER);
219 xidata = allocMap (0, 1, 0, 0, 0, 0, 0, XIDATA_NAME, 'F', FPOINTER);
220 xinit = allocMap (0, 1, 0, 0, 0, 1, 0, XINIT_NAME, 'C', CPOINTER);
222 /* Indirectly addressed internal data segment
230 POINTER-TYPE - IPOINTER
233 idata = allocMap (0, 0, 0, 0, 0, 0, options.idata_loc,
234 IDATA_NAME, 'G', IPOINTER);
247 POINTER-TYPE - _NONE_
249 bit = allocMap (0, 0, 0, 1, 1, 0, 0, BIT_NAME, 'H', 0);
251 /* Special function register space :-
259 POINTER-TYPE - _NONE_
261 sfr = allocMap (1, 0, 0, 1, 0, 0, 0, REG_NAME, 'I', 0);
271 POINTER-TYPE - _NONE_
273 reg = allocMap (1, 0, 0, 0, 0, 0, 0, REG_NAME, ' ', 0);
283 POINTER-TYPE - _NONE_
285 sfrbit = allocMap (1, 0, 0, 1, 1, 0, 0, REG_NAME, 'J', 0);
295 POINTER-TYPE - EEPPOINTER
297 eeprom = allocMap (0, 1, 0, 0, 0, 0, 0, REG_NAME, 'K', EEPPOINTER);
299 /* the unknown map */
300 generic = allocMap (1, 0, 0, 1, 1, 0, 0, REG_NAME, ' ', GPOINTER);
304 /*-----------------------------------------------------------------*/
305 /* allocIntoSeg - puts a symbol into a memory segment */
306 /*-----------------------------------------------------------------*/
308 allocIntoSeg (symbol * sym)
310 memmap *segment = SPEC_OCLS (sym->etype);
311 addSet (&segment->syms, sym);
312 if (segment == pdata)
316 /*-----------------------------------------------------------------*/
317 /* deleteFromSeg - deletes a symbol from segment used when a var */
318 /* first declared as "extern" then no extern */
319 /*-----------------------------------------------------------------*/
320 void deleteFromSeg(symbol *sym)
322 if (SPEC_OCLS(sym->etype)) {
323 memmap *segment = SPEC_OCLS (sym->etype);
324 deleteSetItem(&segment->syms,sym);
328 /*-----------------------------------------------------------------*/
329 /* allocDefault - assigns the output segment based on SCLASS */
330 /*-----------------------------------------------------------------*/
332 allocDefault (symbol * sym)
334 switch (SPEC_SCLS (sym->etype))
337 SPEC_OCLS (sym->etype) = sfr;
340 SPEC_OCLS (sym->etype) = sfrbit;
345 /* if code change to constant */
346 if (sym->ival && (sym->level==0) && SPEC_ABSA(sym->etype)) {
347 SPEC_OCLS(sym->etype) = c_abs;
349 SPEC_OCLS (sym->etype) = statsg;
353 // should we move this to the initialized data segment?
354 if (port->genXINIT &&
355 sym->ival && (sym->level==0) && !SPEC_ABSA(sym->etype)) {
356 SPEC_OCLS(sym->etype) = xidata;
358 SPEC_OCLS (sym->etype) = xdata;
362 SPEC_OCLS (sym->etype) = data;
365 SPEC_OCLS (sym->etype) = idata;
369 SPEC_OCLS (sym->etype) = pdata;
373 SPEC_OCLS (sym->etype) = bit;
376 SPEC_OCLS (sym->etype) = eeprom;
385 /*-----------------------------------------------------------------*/
386 /* allocGlobal - assigns the output segment to a global var */
387 /*-----------------------------------------------------------------*/
389 allocGlobal (symbol * sym)
392 /* symbol name is internal name */
393 if (!sym->level) /* local statics can come here */
394 SNPRINTF (sym->rname, sizeof(sym->rname),
395 "%s%s", port->fun_prefix, sym->name);
397 /* add it to the operandKey reset */
398 if (!isinSet (operKeyReset, sym)) {
399 addSet(&operKeyReset, sym);
402 /* if this is a literal e.g. enumerated type */
403 /* put it in the data segment & do nothing */
404 if (IS_LITERAL (sym->etype))
406 SPEC_OCLS (sym->etype) = data;
410 /* if this is a function then assign code space */
411 if (IS_FUNC (sym->type))
413 SPEC_OCLS (sym->etype) = code;
414 /* if this is an interrupt service routine
415 then put it in the interrupt service array */
416 if (FUNC_ISISR (sym->type) && !options.noiv
417 && (FUNC_INTNO (sym->type) != INTNO_UNSPEC))
419 if (interrupts[FUNC_INTNO (sym->type)])
420 werror (E_INT_DEFINED,
421 FUNC_INTNO (sym->type),
422 interrupts[FUNC_INTNO (sym->type)]->name);
424 interrupts[FUNC_INTNO (sym->type)] = sym;
426 /* automagically extend the maximum interrupts */
427 if (FUNC_INTNO (sym->type) >= maxInterrupts)
428 maxInterrupts = FUNC_INTNO (sym->type) + 1;
430 /* if it is not compiler defined */
437 /* if this is a bit variable and no storage class */
438 if (IS_SPEC(sym->type) && SPEC_NOUN (sym->type) == V_BIT)
439 /*&& SPEC_SCLS (sym->etype) == S_BIT*/
441 SPEC_OCLS (sym->type) = bit;
446 if(!TARGET_IS_PIC16 || (TARGET_IS_PIC16 && sym->level))
447 /* register storage class ignored changed to FIXED */
448 if (SPEC_SCLS (sym->etype) == S_REGISTER)
449 SPEC_SCLS (sym->etype) = S_FIXED;
451 /* if it is fixed, then allocate depending on the */
452 /* current memory model, same for automatics */
453 if (SPEC_SCLS (sym->etype) == S_FIXED ||
454 (TARGET_IS_PIC16 && (SPEC_SCLS (sym->etype) == S_REGISTER) && (sym->level==0)) ||
455 SPEC_SCLS (sym->etype) == S_AUTO) {
456 if (port->mem.default_globl_map != xdata) {
457 /* set the output class */
458 SPEC_OCLS (sym->etype) = port->mem.default_globl_map;
459 /* generate the symbol */
463 SPEC_SCLS (sym->etype) = S_XDATA;
471 /*-----------------------------------------------------------------*/
472 /* allocParms - parameters are always passed on stack */
473 /*-----------------------------------------------------------------*/
475 allocParms (value * val)
480 for (lval = val; lval; lval = lval->next, pNum++)
482 /* check the declaration */
483 checkDecl (lval->sym, 0);
485 /* if this a register parm then allocate
486 it as a local variable by adding it
487 to the first block we see in the body */
488 if (IS_REGPARM (lval->etype))
491 /* mark it as my parameter */
492 lval->sym->ismyparm = 1;
493 lval->sym->localof = currFunc;
495 /* if automatic variables r 2b stacked */
496 if (options.stackAuto || IFFUNC_ISREENT (currFunc->type))
499 lval->sym->onStack = 1;
501 /* choose which stack 2 use */
502 /* use xternal stack */
503 if (options.useXstack)
505 /* PENDING: stack direction support */
506 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = xstack;
507 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
508 xstackPtr - getSize (lval->type);
509 xstackPtr -= getSize (lval->type);
512 { /* use internal stack */
513 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) = istack;
514 if (port->stack.direction > 0)
516 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
517 stackPtr - (FUNC_REGBANK (currFunc->type) ? port->stack.bank_overhead : 0) -
518 getSize (lval->type) -
519 (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0);
520 stackPtr -= getSize (lval->type);
524 /* This looks like the wrong order but it turns out OK... */
525 /* PENDING: isr, bank overhead, ... */
526 SPEC_STAK (lval->etype) = SPEC_STAK (lval->sym->etype) = lval->sym->stack =
528 ((IFFUNC_ISBANKEDCALL (currFunc->type) && !SPEC_STAT(getSpec(currFunc->etype)))? port->stack.banked_overhead : 0) +
529 (FUNC_ISISR (currFunc->type) ? port->stack.isr_overhead : 0) +
531 stackPtr += getSize (lval->type);
534 allocIntoSeg (lval->sym);
537 { /* allocate them in the automatic space */
538 /* generate a unique name */
539 SNPRINTF (lval->sym->rname, sizeof(lval->sym->rname),
540 "%s%s_PARM_%d", port->fun_prefix, currFunc->name, pNum);
541 strncpyz (lval->name, lval->sym->rname, sizeof(lval->name));
543 /* if declared in specific storage */
544 if (allocDefault (lval->sym))
546 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype);
550 /* otherwise depending on the memory model */
551 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
552 port->mem.default_local_map;
553 if (options.model == MODEL_SMALL)
555 /* note here that we put it into the overlay segment
556 first, we will remove it from the overlay segment
557 after the overlay determination has been done */
558 if (!options.noOverlay)
560 SPEC_OCLS (lval->etype) = SPEC_OCLS (lval->sym->etype) =
564 else if (options.model == MODEL_MEDIUM)
566 SPEC_SCLS (lval->etype) = S_PDATA;
570 SPEC_SCLS (lval->etype) = S_XDATA;
572 allocIntoSeg (lval->sym);
578 /*-----------------------------------------------------------------*/
579 /* deallocParms - parameters are always passed on stack */
580 /*-----------------------------------------------------------------*/
582 deallocParms (value * val)
586 for (lval = val; lval; lval = lval->next)
588 /* unmark is myparm */
589 lval->sym->ismyparm = 0;
591 /* delete it from the symbol table */
592 deleteSym (SymbolTab, lval->sym, lval->sym->name);
594 if (!lval->sym->isref)
596 lval->sym->allocreq = 0;
597 werror (W_NO_REFERENCE,
598 currFunc ? currFunc->name : "(unknown)",
599 "function argument", lval->sym->name);
602 /* move the rname if any to the name for both val & sym */
603 /* and leave a copy of it in the symbol table */
604 if (lval->sym->rname[0])
606 char buffer[SDCC_NAME_MAX];
607 strncpyz (buffer, lval->sym->rname, sizeof(buffer));
608 lval->sym = copySymbol (lval->sym);
609 strncpyz (lval->sym->rname, buffer, sizeof(lval->sym->rname));
610 strncpyz (lval->sym->name, buffer, sizeof(lval->sym->name));
611 strncpyz (lval->name, buffer, sizeof(lval->name));
612 addSym (SymbolTab, lval->sym, lval->sym->name,
613 lval->sym->level, lval->sym->block, 1);
614 lval->sym->_isparm = 1;
615 if (!isinSet (operKeyReset, lval->sym))
617 addSet(&operKeyReset, lval->sym);
624 /*-----------------------------------------------------------------*/
625 /* allocLocal - allocate local variables */
626 /*-----------------------------------------------------------------*/
628 allocLocal (symbol * sym)
630 /* generate an unique name */
631 SNPRINTF (sym->rname, sizeof(sym->rname),
634 currFunc->name, sym->name, sym->level, sym->block);
637 sym->localof = currFunc;
639 /* if this is a static variable */
640 if (IS_STATIC (sym->etype))
647 /* if volatile then */
648 if (IS_VOLATILE (sym->etype))
651 /* this is automatic */
653 /* if it's to be placed on the stack */
654 if (options.stackAuto || reentrant) {
656 if (options.useXstack) {
657 /* PENDING: stack direction for xstack */
658 SPEC_OCLS (sym->etype) = xstack;
659 SPEC_STAK (sym->etype) = sym->stack = (xstackPtr + 1);
660 xstackPtr += getSize (sym->type);
662 SPEC_OCLS (sym->etype) = istack;
663 if (port->stack.direction > 0) {
664 SPEC_STAK (sym->etype) = sym->stack = (stackPtr + 1);
665 stackPtr += getSize (sym->type);
667 stackPtr -= getSize (sym->type);
668 SPEC_STAK (sym->etype) = sym->stack = stackPtr;
675 /* else depending on the storage class specified */
677 /* if this is a function then assign code space */
678 if (IS_FUNC (sym->type))
680 SPEC_OCLS (sym->etype) = code;
684 /* if this is a bit variable and no storage class */
685 if (IS_SPEC(sym->type) && SPEC_NOUN (sym->type) == V_BIT)
687 SPEC_SCLS (sym->type) = S_BIT;
688 SPEC_OCLS (sym->type) = bit;
693 if ((SPEC_SCLS (sym->etype) == S_DATA) || (SPEC_SCLS (sym->etype) == S_REGISTER))
695 SPEC_OCLS (sym->etype) = (options.noOverlay ? data : overlay);
700 if (allocDefault (sym))
705 /* again note that we have put it into the overlay segment
706 will remove and put into the 'data' segment if required after
707 overlay analysis has been done */
708 if (options.model == MODEL_SMALL) {
709 SPEC_OCLS (sym->etype) =
710 (options.noOverlay ? port->mem.default_local_map : overlay);
712 SPEC_OCLS (sym->etype) = port->mem.default_local_map;
717 /*-----------------------------------------------------------------*/
718 /* deallocLocal - deallocates the local variables */
719 /*-----------------------------------------------------------------*/
721 deallocLocal (symbol * csym)
725 for (sym = csym; sym; sym = sym->next)
730 /* if it is on the stack */
733 if (options.useXstack)
734 xstackPtr -= getSize (sym->type);
736 stackPtr -= getSize (sym->type);
738 /* if not used give a warning */
739 if (!sym->isref && !IS_STATIC (sym->etype))
740 werror (W_NO_REFERENCE,
741 currFunc ? currFunc->name : "(unknown)",
742 "local variable", sym->name);
743 /* now delete it from the symbol table */
744 deleteSym (SymbolTab, sym, sym->name);
748 /*-----------------------------------------------------------------*/
749 /* overlay2data - moves declarations from the overlay seg to data */
750 /*-----------------------------------------------------------------*/
756 for (sym = setFirstItem (overlay->syms); sym;
757 sym = setNextItem (overlay->syms))
760 SPEC_OCLS (sym->etype) = data;
764 setToNull ((void *) &overlay->syms);
768 /*-----------------------------------------------------------------*/
769 /* overlay2Set - will add all symbols from the overlay segment to */
770 /* the set of sets containing the overlable symbols */
771 /*-----------------------------------------------------------------*/
778 for (sym = setFirstItem (overlay->syms); sym;
779 sym = setNextItem (overlay->syms))
785 setToNull ((void *) &overlay->syms);
786 addSet (&ovrSetSets, oset);
790 /*-----------------------------------------------------------------*/
791 /* allocVariables - creates decl & assign storage class for a v */
792 /*-----------------------------------------------------------------*/
794 allocVariables (symbol * symChain)
801 /* go thru the symbol chain */
802 for (sym = symChain; sym; sym = sym->next)
805 /* if this is a typedef then add it */
806 /* to the typedef table */
807 if (IS_TYPEDEF (sym->etype))
809 /* check if the typedef already exists */
810 csym = findSym (TypedefTab, NULL, sym->name);
811 if (csym && csym->level == sym->level)
812 werror (E_DUPLICATE_TYPEDEF, sym->name);
814 SPEC_EXTR (sym->etype) = 0;
815 addSym (TypedefTab, sym, sym->name, sym->level, sym->block, 0);
816 continue; /* go to the next one */
818 /* make sure it already exist */
819 csym = findSymWithLevel (SymbolTab, sym);
820 if (!csym || (csym && csym->level != sym->level))
823 /* check the declaration */
826 /* if this is a function or a pointer to function */
827 /* then args processing */
828 if (funcInChain (csym->type))
830 processFuncArgs (csym);
832 /* if register bank specified then update maxRegBank */
833 if (maxRegBank < FUNC_REGBANK (csym->type))
834 maxRegBank = FUNC_REGBANK (csym->type);
835 /*JCF: Mark the register bank as used*/
836 RegBankUsed[FUNC_REGBANK(csym->type)]=1;
839 /* if this is a extern variable then change the */
840 /* level to zero temporarily */
841 if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
843 saveLevel = csym->level;
847 /* if this is a literal then it is an enumerated */
848 /* type so need not allocate it space for it */
849 if (IS_LITERAL (sym->etype))
852 /* generate the actual declaration */
857 stack += getSize (csym->type);
862 /* restore the level */
863 if (IS_EXTERN (csym->etype) || IS_FUNC (csym->type))
864 csym->level = saveLevel;
870 /*-----------------------------------------------------------------*/
871 /* redoStackOffsets :- will reassign the values for stack offsets */
872 /*-----------------------------------------------------------------*/
874 redoStackOffsets (void)
880 /* after register allocation is complete we know
881 which variables will need to be assigned space
882 on the stack. We will eliminate those variables
883 which do not have the allocReq flag thus reducing
885 for (sym = setFirstItem (istack->syms); sym;
886 sym = setNextItem (istack->syms))
889 int size = getSize (sym->type);
890 /* nothing to do with parameters so continue */
891 if ((sym->_isparm && !IS_REGPARM (sym->etype)))
894 if (IS_AGGREGATE (sym->type))
896 if (port->stack.direction > 0)
898 SPEC_STAK (sym->etype) = sym->stack = (sPtr + 1);
904 SPEC_STAK (sym->etype) = sym->stack = sPtr;
909 /* if allocation not required then subtract
910 size from overall stack size & continue */
913 currFunc->stack -= size;
914 SPEC_STAK (currFunc->etype) -= size;
918 if (port->stack.direction > 0)
920 SPEC_STAK (sym->etype) = sym->stack = (sPtr + 1);
926 SPEC_STAK (sym->etype) = sym->stack = sPtr;
930 /* do the same for the external stack */
932 for (sym = setFirstItem (xstack->syms); sym;
933 sym = setNextItem (xstack->syms))
936 int size = getSize (sym->type);
937 /* nothing to do with parameters so continue */
938 if ((sym->_isparm && !IS_REGPARM (sym->etype)))
941 if (IS_AGGREGATE (sym->type))
943 SPEC_STAK (sym->etype) = sym->stack = (xsPtr + 1);
948 /* if allocation not required then subtract
949 size from overall stack size & continue */
952 currFunc->xstack -= size;
953 SPEC_STAK (currFunc->etype) -= size;
957 SPEC_STAK (sym->etype) = sym->stack = (xsPtr + 1);
963 /*-----------------------------------------------------------------*/
964 /* printAllocInfoSeg- print the allocation for a given section */
965 /*-----------------------------------------------------------------*/
967 printAllocInfoSeg (memmap * map, symbol * func, FILE * of)
976 for (sym = setFirstItem (map->syms); sym;
977 sym = setNextItem (map->syms))
982 if (sym->localof != func)
985 fprintf (of, ";%-25s Allocated ", sym->name);
987 /* if assigned to registers */
988 if (!sym->allocreq && sym->reqv)
992 sym = OP_SYMBOL (sym->reqv);
993 if (!sym->isspilt || sym->remat)
995 fprintf (of, "to registers ");
996 for (i = 0; i < 4 && sym->regs[i]; i++)
997 fprintf (of, "%s ", port->getRegName (sym->regs[i]));
1003 sym = sym->usl.spillLoc;
1010 fprintf (of, "to stack - offset %d\n", sym->stack);
1014 /* otherwise give rname */
1015 fprintf (of, "with name '%s'\n", sym->rname);
1019 /*-----------------------------------------------------------------*/
1020 /* canOverlayLocals - returns true if the local variables can overlayed */
1021 /*-----------------------------------------------------------------*/
1023 canOverlayLocals (eBBlock ** ebbs, int count)
1026 /* if staticAuto is in effect or the current function
1027 being compiled is reentrant or the overlay segment
1028 is empty or no overlay option is in effect then */
1029 if (options.noOverlay ||
1030 options.stackAuto ||
1032 (IFFUNC_ISREENT (currFunc->type) ||
1033 FUNC_ISISR (currFunc->type))) ||
1034 elementsInSet (overlay->syms) == 0)
1038 /* if this is a forces overlay */
1039 if (IFFUNC_ISOVERLAY(currFunc->type)) return TRUE;
1041 /* otherwise do thru the blocks and see if there
1042 any function calls if found then return false */
1043 for (i = 0; i < count; i++)
1047 for (ic = ebbs[i]->sch; ic; ic = ic->next)
1049 if (ic->op == CALL) {
1050 sym_link *ftype = operandType(IC_LEFT(ic));
1051 /* builtins only can use overlays */
1052 if (!IFFUNC_ISBUILTIN(ftype)) return FALSE;
1053 } else if (ic->op == PCALL) return FALSE;
1057 /* no function calls found return TRUE */
1061 /*-----------------------------------------------------------------*/
1062 /* doOverlays - move the overlay segment to appropriate location */
1063 /*-----------------------------------------------------------------*/
1065 doOverlays (eBBlock ** ebbs, int count)
1071 /* check if the parameters and local variables
1072 of this function can be put in the overlay segment
1073 This check is essentially to see if the function
1074 calls any other functions if yes then we cannot
1076 if (canOverlayLocals (ebbs, count))
1077 /* if we can then put the parameters &
1078 local variables in the overlay set */
1081 /* otherwise put them into data where
1086 /*-----------------------------------------------------------------*/
1087 /* printAllocInfo - prints allocation information for a function */
1088 /*-----------------------------------------------------------------*/
1090 printAllocInfo (symbol * func, FILE * of)
1098 /* must be called after register allocation is complete */
1099 fprintf (of, ";------------------------------------------------------------\n");
1100 fprintf (of, ";Allocation info for local variables in function '%s'\n", func->name);
1101 fprintf (of, ";------------------------------------------------------------\n");
1103 printAllocInfoSeg (xstack, func, of);
1104 printAllocInfoSeg (istack, func, of);
1105 printAllocInfoSeg (code, func, of);
1106 printAllocInfoSeg (data, func, of);
1107 printAllocInfoSeg (xdata, func, of);
1108 printAllocInfoSeg (idata, func, of);
1109 printAllocInfoSeg (sfr, func, of);
1110 printAllocInfoSeg (sfrbit, func, of);
1114 set *tempOverlaySyms = overlay->syms;
1116 /* search the set of overlay sets for local variables/parameters */
1117 for (ovrset = setFirstItem (ovrSetSets); ovrset;
1118 ovrset = setNextItem (ovrSetSets))
1120 overlay->syms = ovrset;
1121 printAllocInfoSeg (overlay, func, of);
1123 overlay->syms = tempOverlaySyms;
1126 fprintf (of, ";------------------------------------------------------------\n");