X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fxa51%2Fralloc.c;h=830a30f18d559fad3cbab5e4b78c32e7861e12c2;hb=eae1bd2f705a2c61e143c539f8c4d1e9c2b4efe6;hp=1f530ece925535d57c7da83b39c2841f6329e2a2;hpb=d8c236efd1a19e0622511f35efb1de0c181eab29;p=fw%2Fsdcc diff --git a/src/xa51/ralloc.c b/src/xa51/ralloc.c old mode 100755 new mode 100644 index 1f530ece..830a30f1 --- a/src/xa51/ralloc.c +++ b/src/xa51/ralloc.c @@ -127,7 +127,7 @@ regs *xa51_regWithMask (unsigned long mask) { /* checkRegsMask - check the consistancy of the regMask redundancy */ /*-----------------------------------------------------------------*/ -void checkRegMask(char *f) { // for debugging purposes only +void checkRegMask(const char *f) { // for debugging purposes only int i; unsigned long regMask=0; @@ -199,8 +199,8 @@ static void freeReg (regs * reg, bool silent) { /* allocReg - allocates register of given size (byte, word, dword) */ /* and type (ptr, gpr, cnd) */ /*-----------------------------------------------------------------*/ -static bool allocReg (short size, short type, symbol *sym, - short offset, bool silent) { +static bool allocReg (unsigned int size, int type, symbol *sym, + int offset, bool silent) { int i; checkRegMask(__FUNCTION__); @@ -655,7 +655,9 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym) /* check if there are any live ranges that not used in the remainder of the block */ - if (!_G.blockSpil && (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic))) + if (!_G.blockSpil && + !isiCodeInFunctionCall (ic) && + (selectS = liveRangesWith (lrcs, notUsedInRemaining, ebp, ic))) { sym = leastUsedLR (selectS); if (sym != forSym) @@ -983,7 +985,13 @@ serialRegAssign (eBBlock ** ebbs, int count) bitVect *spillable; int willCS; - /* if it does not need or is spilt + /* Make sure any spill location is definately allocated */ + if (sym->isspilt && !sym->remat && sym->usl.spillLoc && + !sym->usl.spillLoc->allocreq) { + sym->usl.spillLoc->allocreq++; + } + + /* if it does not need or is spilt or is already assigned to registers or will not live beyond this instructions */ if (!sym->nRegs || @@ -1010,6 +1018,16 @@ serialRegAssign (eBBlock ** ebbs, int count) continue; } + /* If the live range preceeds the point of definition + then ideally we must take into account registers that + have been allocated after sym->liveFrom but freed + before ic->seq. This is complicated, so spill this + symbol instead and let fillGaps handle the allocation. */ + if (sym->liveFrom < ic->seq) { + spillThis (sym); + continue; + } + /* if it has a spillocation & is used less than all other live ranges then spill this */ if (willCS) { @@ -1591,8 +1609,6 @@ packRegsForSupport (iCode * ic, eBBlock * ebp) return change; } -#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) - /*-----------------------------------------------------------------*/ /* packRegsForOneuse : - will reduce some registers for single Use */ @@ -2041,8 +2057,10 @@ static void packRegisters (eBBlock * ebp) { /* assignRegisters - assigns registers to each live range as need */ /*-----------------------------------------------------------------*/ void -xa51_assignRegisters (eBBlock ** ebbs, int count) +xa51_assignRegisters (ebbIndex * ebbi) { + eBBlock ** ebbs = ebbi->bbOrder; + int count = ebbi->count; iCode *ic; int i; @@ -2060,7 +2078,7 @@ xa51_assignRegisters (eBBlock ** ebbs, int count) recomputeLiveRanges (ebbs, count); if (options.dump_pack) - dumpEbbsToFileExt (DUMP_PACK, ebbs, count); + dumpEbbsToFileExt (DUMP_PACK, ebbi); /* first determine for each live range the number of registers & the type of registers required for each */ @@ -2088,7 +2106,7 @@ xa51_assignRegisters (eBBlock ** ebbs, int count) if (options.dump_rassgn) { - dumpEbbsToFileExt (DUMP_RASSGN, ebbs, count); + dumpEbbsToFileExt (DUMP_RASSGN, ebbi); dumpLiveRanges (DUMP_LRANGE, liveRanges); }