X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fds390%2Fralloc.c;h=b462b81be9f862eebb6ef310f998450c2c103469;hb=940ddadd79bebcdd9ccf131e03d09de45d088e23;hp=922c68b04089aeca5cfbab85bcbd84626431905f;hpb=affc5e817550e87639314a8c251b2921724415db;p=fw%2Fsdcc diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 922c68b0..b462b81b 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -36,7 +36,7 @@ /* since the pack the registers depending strictly on the MCU */ /*-----------------------------------------------------------------*/ -#define D(x) x +#define D(x) /* Global data */ static struct @@ -1309,7 +1309,9 @@ static void fillGaps() if (sym->uptr && !sym->ruonly && getSize(sym->type) < 4) { if (packRegsDPTRuse(operandFromSymbol(sym))) { - D (printf ("FILL GAPS: found more DPTR use for %s in func %s\n",sym->name, currFunc ? currFunc->name : "UNKNOWN")); + D (fprintf (stderr, "FILL GAPS: found more DPTR use for " + "%s in func %s\n", + sym->name, currFunc ? currFunc->name : "UNKNOWN")); /* if this was ssigned to registers then */ if (bitVectBitValue(_G.totRegAssigned,sym->key)) { @@ -1363,7 +1365,7 @@ static void fillGaps() sym->regs[i] = getRegGprNoSpil (); } - /* for all its definitions check if the registers + /* for all its definitions & uses check if the registers allocated needs positioning NOTE: we can position only ONCE if more than One positioning required then give up */ @@ -1386,18 +1388,36 @@ static void fillGaps() if (pdone > 1) break; } } + for (i = 0 ; i < sym->uses->size ; i++ ) { + if (bitVectBitValue(sym->uses,i)) { + iCode *ic; + if (!(ic = hTabItemWithKey(iCodehTab,i))) continue ; + if (SKIP_IC(ic)) continue; + if (!IS_ASSIGN_ICODE(ic)) continue ; + + /* if result is assigned to registers */ + if (IS_SYMOP(IC_RESULT(ic)) && + bitVectBitValue(_G.totRegAssigned,OP_SYMBOL(IC_RESULT(ic))->key)) { + pdone += positionRegs(sym,OP_SYMBOL(IC_RESULT(ic))); + } + if (pdone > 1) break; + } + } /* had to position more than once GIVE UP */ if (pdone > 1) { /* UNDO all the changes we made to try this */ - sym->isspilt = 0; + sym->isspilt = 1; for (i=0; i < sym->nRegs ; i++ ) { sym->regs[i] = NULL; } freeAllRegs(); - D (printf ("Fill Gap gave up due to positioning for %s in function %s\n",sym->name, currFunc ? currFunc->name : "UNKNOWN")); + D (fprintf (stderr, "Fill Gap gave up due to positioning for " + "%s in function %s\n", + sym->name, currFunc ? currFunc->name : "UNKNOWN")); continue ; } - D (printf ("FILLED GAP for %s in function %s\n",sym->name, currFunc ? currFunc->name : "UNKNOWN")); + D (fprintf (stderr, "FILLED GAP for %s in function %s\n", + sym->name, currFunc ? currFunc->name : "UNKNOWN")); _G.totRegAssigned = bitVectSetBit(_G.totRegAssigned,sym->key); sym->isspilt = sym->spillA = 0 ; sym->usl.spillLoc->allocreq--; @@ -2002,8 +2022,9 @@ findAssignToSym (operand * op, iCode * ic) /*-----------------------------------------------------------------*/ static int packRegsForSupport (iCode * ic, eBBlock * ebp) -{ +{ int change = 0; + /* for the left & right operand :- look to see if the left was assigned a true symbol in far space in that case replace them */ @@ -2118,11 +2139,9 @@ packRegsDPTRuse (operand * op) etype = getSpec(type = operandType(IC_RESULT(ic))); #if 0 if (getSize(type) == 0 || isOperandEqual(op,IC_RESULT(ic))) - continue ; -#else - if (getSize(type)==0) - continue; #endif + if (getSize(type) == 0) + continue ; return NULL ; } @@ -2571,9 +2590,11 @@ packRegisters (eBBlock * ebp) } #endif +#if 0 /* unsafe */ /* reduce for support function calls */ if (ic->supportRtn || ic->op == '+' || ic->op == '-') packRegsForSupport (ic, ebp); +#endif /* some cases the redundant moves can can be eliminated for return statements */ @@ -2584,8 +2605,12 @@ packRegisters (eBBlock * ebp) packRegsDPTRuse (IC_LEFT (ic)); } - if ((ic->op == CALL && getSize(operandType(IC_RESULT(ic))) <= 4)) { - packRegsDPTRuse (IC_RESULT (ic)); + if (ic->op == CALL) { + sym_link *ftype = operandType(IC_LEFT(ic)); + if (getSize(operandType(IC_RESULT(ic))) <= 4 && + !IFFUNC_ISBUILTIN(ftype)) { + packRegsDPTRuse (IC_RESULT (ic)); + } } /* if pointer set & left has a size more than