From c292f3679b277c42cbf293ac18c48548632f7205 Mon Sep 17 00:00:00 2001 From: tecodev Date: Sun, 14 Sep 2008 04:06:11 +0000 Subject: [PATCH] * src/pic16/gen.c, src/pic16/ralloc.c: use SYM_SPIL_LOC/SPIL_LOC macros, no functional changes * src/pic16/ralloc.c (rematStr): reimplemented, fixes #1818857 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5236 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 6 ++++ src/pic16/gen.c | 24 ++++++------- src/pic16/ralloc.c | 85 +++++++++++++++++++--------------------------- 3 files changed, 52 insertions(+), 63 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5305c563..c576667e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-09-14 Raphael Neider + + * src/pic16/gen.c, src/pic16/ralloc.c: use + SYM_SPIL_LOC/SPIL_LOC macros, no functional changes + * src/pic16/ralloc.c (rematStr): reimplemented, fixes #1818857 + 2008-09-12 Borut Razem * support/regression/fwk/testfwk.h: diff --git a/src/pic16/gen.c b/src/pic16/gen.c index 7edff7f4..358a2e26 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -868,14 +868,14 @@ static bool operandsEqu ( operand *op1, operand *op2) if (IS_ITEMP(op1) && !IS_ITEMP(op2) && sym1->isspilt && - (sym1->usl.spillLoc == sym2)) + (SYM_SPIL_LOC(sym1) == sym2)) return TRUE; if (IS_ITEMP(op2) && !IS_ITEMP(op1) && sym2->isspilt && sym1->level > 0 && - (sym2->usl.spillLoc == sym1)) + (SYM_SPIL_LOC(sym2) == sym1)) return TRUE ; return FALSE ; @@ -1019,7 +1019,7 @@ void pic16_aopOp (operand *op, iCode *ic, bool result) aop->size = getSize(sym->type); for ( i = 0 ; i < 1 ; i++ ) { aop->aopu.aop_str[i] = accUse[i]; -// aop->aopu.pcop = pic16_popRegFromString("WREG", aop->size, sym->usl.spillLoc->offset); +// aop->aopu.pcop = pic16_popRegFromString("WREG", aop->size, SYM_SPIL_LOC(sym)->offset); } fprintf(stderr, "%s:%d allocating AOP_ACC for sym= %s\n", __FILE__, __LINE__, sym->name); DEBUGpic16_emitcode(";","%d size=%d",__LINE__,aop->size); @@ -1031,7 +1031,7 @@ void pic16_aopOp (operand *op, iCode *ic, bool result) if (sym->ruonly) { /* sym->aop = op->aop = aop = newAsmop(AOP_PCODE); - aop->aopu.pcop = pic16_popGetImmd(sym->usl.spillLoc->rname,0,sym->usl.spillLoc->offset); + aop->aopu.pcop = pic16_popGetImmd(SYM_SPIL_LOC(sym)->rname,0,SYM_SPIL_LOC(sym)->offset); //pic16_allocDirReg (IC_LEFT(ic)); aop->size = getSize(sym->type); */ @@ -1048,24 +1048,24 @@ void pic16_aopOp (operand *op, iCode *ic, bool result) } #endif /* else spill location */ - if (sym->usl.spillLoc && getSize(sym->type) != getSize(sym->usl.spillLoc->type)) { + if (SYM_SPIL_LOC(sym) && getSize(sym->type) != getSize(SYM_SPIL_LOC(sym)->type)) { /* force a new aop if sizes differ */ - sym->usl.spillLoc->aop = NULL; + SYM_SPIL_LOC(sym)->aop = NULL; } #if 0 DEBUGpic16_emitcode(";","%s %d %s sym->rname = %s, offset %d", __FUNCTION__,__LINE__, - sym->usl.spillLoc->rname, - sym->rname, sym->usl.spillLoc->offset); + SYM_SPIL_LOC(sym)->rname, + sym->rname, SYM_SPIL_LOC(sym)->offset); #endif - //aop->aopu.pcop = pic16_popGetImmd(sym->usl.spillLoc->rname,0,sym->usl.spillLoc->offset); - if (sym->usl.spillLoc && sym->usl.spillLoc->rname) { + //aop->aopu.pcop = pic16_popGetImmd(SYM_SPIL_LOC(sym)->rname,0,SYM_SPIL_LOC(sym)->offset); + if (SYM_SPIL_LOC(sym) && SYM_SPIL_LOC(sym)->rname) { sym->aop = op->aop = aop = newAsmop(AOP_PCODE); - aop->aopu.pcop = pic16_popRegFromString(sym->usl.spillLoc->rname, + aop->aopu.pcop = pic16_popRegFromString(SYM_SPIL_LOC(sym)->rname, getSize(sym->type), - sym->usl.spillLoc->offset, op); + SYM_SPIL_LOC(sym)->offset, op); } else if (getSize(sym->type) <= 1) { //fprintf (stderr, "%s:%d called for a spillLocation -- assigning WREG instead --- CHECK (size:%u)!\n", __FUNCTION__, __LINE__, getSize(sym->type)); pic16_emitpcomment (";!!! %s:%d called for a spillLocation -- assigning WREG instead --- CHECK", __FUNCTION__, __LINE__); diff --git a/src/pic16/ralloc.c b/src/pic16/ralloc.c index 1f175201..b61225f3 100644 --- a/src/pic16/ralloc.c +++ b/src/pic16/ralloc.c @@ -1380,7 +1380,7 @@ static int noSpilLoc (symbol * sym, eBBlock * ebp, iCode * ic) { debugLog ("%s\n", __FUNCTION__); - return (sym->usl.spillLoc ? 0 : 1); + return (SYM_SPIL_LOC (sym) ? 0 : 1); } /*-----------------------------------------------------------------*/ @@ -1390,7 +1390,7 @@ static int hasSpilLoc (symbol * sym, eBBlock * ebp, iCode * ic) { debugLog ("%s\n", __FUNCTION__); - return (sym->usl.spillLoc ? 1 : 0); + return (SYM_SPIL_LOC (sym) ? 1 : 0); } /*-----------------------------------------------------------------*/ @@ -1400,8 +1400,8 @@ static int directSpilLoc (symbol * sym, eBBlock * ebp, iCode * ic) { debugLog ("%s\n", __FUNCTION__); - if (sym->usl.spillLoc && - (IN_DIRSPACE (SPEC_OCLS (sym->usl.spillLoc->etype)))) + if (SYM_SPIL_LOC (sym) && + (IN_DIRSPACE (SPEC_OCLS (SYM_SPIL_LOC (sym)->etype)))) return 1; else return 0; @@ -1415,7 +1415,7 @@ static int hasSpilLocnoUptr (symbol * sym, eBBlock * ebp, iCode * ic) { debugLog ("%s\n", __FUNCTION__); - return ((sym->usl.spillLoc && !sym->uptr) ? 1 : 0); + return ((SYM_SPIL_LOC (sym) && !sym->uptr) ? 1 : 0); } /*-----------------------------------------------------------------*/ @@ -1634,7 +1634,7 @@ createStackSpil (symbol * sym) if (applyToSet (_G.stackSpil, isFree, &sloc, sym)) { /* found a free one : just update & return */ - sym->usl.spillLoc = sloc; + SYM_SPIL_LOC (sym) = sloc; sym->stackSpil = 1; sloc->isFree = 0; addSetHead (&sloc->usl.itmpStack, sym); @@ -1693,7 +1693,7 @@ createStackSpil (symbol * sym) /* add it to the _G.stackSpil set */ addSetHead (&_G.stackSpil, sloc); - sym->usl.spillLoc = sloc; + SYM_SPIL_LOC (sym) = sloc; sym->stackSpil = 1; /* add it to the set of itempStack set @@ -1720,10 +1720,10 @@ isSpiltOnStack (symbol * sym) /* if (sym->_G.stackSpil) */ /* return TRUE; */ - if (!sym->usl.spillLoc) + if (!SYM_SPIL_LOC (sym)) return FALSE; - etype = getSpec (sym->usl.spillLoc->type); + etype = getSpec (SYM_SPIL_LOC (sym)->type); if (IN_STACK (etype)) return TRUE; @@ -1742,7 +1742,7 @@ spillThis (symbol * sym) /* if this is rematerializable or has a spillLocation we are okay, else we need to create a spillLocation for it */ - if (!(sym->remat || sym->usl.spillLoc)) + if (!(sym->remat || SYM_SPIL_LOC (sym))) createStackSpil (sym); @@ -1769,8 +1769,8 @@ spillThis (symbol * sym) spillLRWithPtrReg (sym); } - if (sym->usl.spillLoc && !sym->remat) - sym->usl.spillLoc->allocreq = 1; + if (SYM_SPIL_LOC (sym) && !sym->remat) + SYM_SPIL_LOC (sym)->allocreq = 1; return; } @@ -1800,12 +1800,12 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym) if ((selectS = liveRangesWith (lrcs, directSpilLoc, ebp, ic))) { sym = leastUsedLR (selectS); - strcpy (sym->rname, (sym->usl.spillLoc->rname[0] ? - sym->usl.spillLoc->rname : - sym->usl.spillLoc->name)); + strcpy (sym->rname, (SYM_SPIL_LOC (sym)->rname[0] ? + SYM_SPIL_LOC (sym)->rname : + SYM_SPIL_LOC (sym)->name)); sym->spildir = 1; /* mark it as allocation required */ - sym->usl.spillLoc->allocreq = 1; + SYM_SPIL_LOC (sym)->allocreq = 1; return sym; } @@ -1849,7 +1849,7 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym) sym = leastUsedLR (selectS); /* mark this as allocation required */ - sym->usl.spillLoc->allocreq = 1; + SYM_SPIL_LOC (sym)->allocreq = 1; return sym; } @@ -1858,7 +1858,7 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym) { sym = leastUsedLR (selectS); - sym->usl.spillLoc->allocreq = 1; + SYM_SPIL_LOC (sym)->allocreq = 1; return sym; } @@ -1870,7 +1870,7 @@ selectSpil (iCode * ic, eBBlock * ebp, symbol * forSym) /* return a created spil location */ sym = createStackSpil (leastUsedLR (selectS)); - sym->usl.spillLoc->allocreq = 1; + SYM_SPIL_LOC (sym)->allocreq = 1; return sym; } @@ -2058,7 +2058,7 @@ deassignLRs (iCode * ic, eBBlock * ebp) { if (sym->stackSpil) { - sym->usl.spillLoc->isFree = 1; + SYM_SPIL_LOC (sym)->isFree = 1; sym->stackSpil = 0; } continue; @@ -2340,10 +2340,10 @@ serialRegAssign (eBBlock ** ebbs, int count) int ptrRegSet = 0; /* Make sure any spill location is definately allocated */ - if (sym->isspilt && !sym->remat && sym->usl.spillLoc && - !sym->usl.spillLoc->allocreq) + if (sym->isspilt && !sym->remat && SYM_SPIL_LOC (sym) && + !SYM_SPIL_LOC (sym)->allocreq) { - sym->usl.spillLoc->allocreq++; + SYM_SPIL_LOC (sym)->allocreq++; } /* if it does not need or is spilt @@ -2397,7 +2397,7 @@ serialRegAssign (eBBlock ** ebbs, int count) /* if it has a spillocation & is used less than all other live ranges then spill this */ if (willCS) { - if (sym->usl.spillLoc) { + if (SYM_SPIL_LOC (sym)) { symbol *leastUsed = leastUsedLR (liveRangesWith (spillable, allLRs, ebbs[i], ic)); if (leastUsed && leastUsed->used > sym->used) { @@ -2673,38 +2673,21 @@ createRegMask (eBBlock ** ebbs, int count) static symbol * rematStr (symbol * sym) { - char *s = buffer; iCode *ic = sym->rematiCode; symbol *psym = NULL; + int offset = 0; debugLog ("%s\n", __FUNCTION__); - //printf ("%s\n", s); - - /* if plus or minus print the right hand side */ - - if (ic->op == '+' || ic->op == '-') { - - iCode *ric = OP_SYMBOL (IC_LEFT (ic))->rematiCode; - - sprintf (s, "(%s %c 0x%04x)", - OP_SYMBOL (IC_LEFT (ric))->rname, - ic->op, - (int) operandLitValue (IC_RIGHT (ic))); + while (ic->op == '+' || ic->op == '-') { + /* if plus or minus print the right hand side */ + offset += (int) operandLitValue (IC_RIGHT (ic)); + ic = OP_SYMBOL (IC_LEFT (ic))->rematiCode; + } // while - //fprintf(stderr, "ralloc.c:%d OOPS %s\n",__LINE__,s); - - psym = newSymbol (OP_SYMBOL (IC_LEFT (ric))->rname, 1); - psym->offset = (int) operandLitValue (IC_RIGHT (ic)); - - return psym; - } - - sprintf (s, "%s", OP_SYMBOL (IC_LEFT (ic))->rname); psym = newSymbol (OP_SYMBOL (IC_LEFT (ic))->rname, 1); - - //printf ("ralloc.c:%d %s\n", __LINE__,buffer); + psym->offset = offset; return psym; } @@ -2826,7 +2809,7 @@ regTypeNum () psym->psbase = ptrBaseRematSym (OP_SYMBOL (IC_LEFT (ic))); strcpy (psym->rname, psym->name); sym->isspilt = 1; - sym->usl.spillLoc = psym; + SYM_SPIL_LOC (sym) = psym; continue; } @@ -4031,7 +4014,7 @@ pic16_packRegisters (eBBlock * ebp) OP_SYMBOL (IC_RESULT (ic))->remat = 1; OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic; - OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL; + SPIL_LOC (IC_RESULT (ic)) = NULL; } @@ -4065,7 +4048,7 @@ pic16_packRegisters (eBBlock * ebp) operandLitValue (IC_RIGHT (ic)); OP_SYMBOL (IC_RESULT (ic))->remat = 1; OP_SYMBOL (IC_RESULT (ic))->rematiCode = ic; - OP_SYMBOL (IC_RESULT (ic))->usl.spillLoc = NULL; + SPIL_LOC (IC_RESULT (ic)) = NULL; } -- 2.30.2