From: epetrich Date: Sat, 24 Apr 2004 07:06:41 +0000 (+0000) Subject: * src/SDCCpeeph.c (replaceRule): support empty replacement peephole X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=7faa2c7f7e56d31567f05ae41a0c431f9bced6de;p=fw%2Fsdcc * src/SDCCpeeph.c (replaceRule): support empty replacement peephole rules * src/SDCCmain.c, * src/SDCCglobl.h, * src/SDCCpeeph.c (getPeepLine): new option --no-peep-comments omits comments from the peephole optimizer replacement rules * src/SDCCmem.c (printAllocInfoSeg): give actual location of spilled symbols * src/SDCCcse.c (updateSpillLocation), * src/SDCCopt.c (killDeadCode, findReqv): better tracking of register equivalents * src/hc08/ralloc.c (regTypeNum): pseudo symbols must be in DATA only * src/hc08/main.c (_hc08_finaliseOptions): made pointers to stack objects far pointers git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3299 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index edb3d273..33725264 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2004-04-24 Erik Petrich + + * src/SDCCpeeph.c (replaceRule): support empty replacement peephole + rules + * src/SDCCmain.c, + * src/SDCCglobl.h, + * src/SDCCpeeph.c (getPeepLine): new option --no-peep-comments omits + comments from the peephole optimizer replacement rules + * src/SDCCmem.c (printAllocInfoSeg): give actual location of spilled + symbols + * src/SDCCcse.c (updateSpillLocation), + * src/SDCCopt.c (killDeadCode, findReqv): better tracking of register + equivalents + * src/hc08/ralloc.c (regTypeNum): pseudo symbols must be in DATA only + * src/hc08/main.c (_hc08_finaliseOptions): made pointers to stack + objects far pointers + 2004-04-23 Erik Petrich * src/SDCCsymt.h: a missing part of my last change diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 1466760c..c5750920 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -1296,10 +1296,13 @@ updateSpillLocation (iCode * ic, int induction) if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc && !IS_VOLATILE (setype) && !IN_FARSPACE (SPEC_OCLS (setype)) && - !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic)))) + !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic)))) { SPIL_LOC (IC_RIGHT (ic)) = SPIL_LOC (IC_RESULT (ic)); + OP_SYMBOL (IC_RIGHT (ic))->prereqv = + OP_SYMBOL (IC_RESULT (ic))->prereqv; + } } /* special case for inductions */ if (induction && @@ -1307,6 +1310,8 @@ updateSpillLocation (iCode * ic, int induction) !OP_SYMBOL(IC_RESULT (ic))->noSpilLoc && !SPIL_LOC(IC_RESULT(ic))) { SPIL_LOC (IC_RESULT (ic)) = SPIL_LOC (IC_RIGHT (ic)); + OP_SYMBOL (IC_RESULT (ic))->prereqv = + OP_SYMBOL (IC_RIGHT (ic))->prereqv; } } } diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 687d9075..3643e5f4 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -243,6 +243,7 @@ struct options int noXinitOpt; /* don't optimize initialized xdata */ int noCcodeInAsm; /* hide c-code from asm */ int iCodeInAsm; /* show i-code in asm */ + int noPeepComments; /* hide peephole optimizer comments */ int printSearchDirs; /* display the directories in the compiler's search path */ int vc_err_style; /* errors and warnings are compatible with Micro$oft visual studio */ int use_stdout; /* send errors to stdout instead of stderr */ diff --git a/src/SDCCmain.c b/src/SDCCmain.c index fb8cfa76..3231e34c 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -126,6 +126,7 @@ char buffer[PATH_MAX * 2]; #define OPTION_USE_STDOUT "--use-stdout" #define OPTION_STACK_SIZE "--stack-size" #define OPTION_PACK_IRAM "--pack-iram" +#define OPTION_NO_PEEP_COMMENTS "--no-peep-comments" static const OPTION optionsTable[] = { @@ -226,6 +227,7 @@ optionsTable[] = { { 0, OPTION_NO_XINIT_OPT, &options.noXinitOpt, "don't memcpy initialized xram from code"}, { 0, OPTION_NO_CCODE_IN_ASM, &options.noCcodeInAsm, "don't include c-code as comments in the asm file"}, { 0, OPTION_ICODE_IN_ASM, &options.iCodeInAsm, "include i-code as comments in the asm file"}, + { 0, OPTION_NO_PEEP_COMMENTS, &options.noPeepComments, "don't include peephole optimizer comments"}, { 0, OPTION_PRINT_SEARCH_DIRS, &options.printSearchDirs, "display the directories in the compiler's search path"}, { 0, OPTION_MSVC_ERROR_STYLE, &options.vc_err_style, "messages are compatible with Micro$oft visual studio"}, { 0, OPTION_USE_STDOUT, &options.use_stdout, "send errors to stdout instead of stderr"}, diff --git a/src/SDCCmem.c b/src/SDCCmem.c index ba185d24..dc0982b4 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -994,11 +994,18 @@ printAllocInfoSeg (memmap * map, symbol * func, FILE * of) int i; sym = OP_SYMBOL (sym->reqv); - fprintf (of, "to registers "); - for (i = 0; i < 4 && sym->regs[i]; i++) - fprintf (of, "%s ", port->getRegName (sym->regs[i])); - fprintf (of, "\n"); - continue; + if (!sym->isspilt || sym->remat) + { + fprintf (of, "to registers "); + for (i = 0; i < 4 && sym->regs[i]; i++) + fprintf (of, "%s ", port->getRegName (sym->regs[i])); + fprintf (of, "\n"); + continue; + } + else + { + sym = sym->usl.spillLoc; + } } /* if on stack */ diff --git a/src/SDCCopt.c b/src/SDCCopt.c index cfb416d9..4e9c2a7b 100644 --- a/src/SDCCopt.c +++ b/src/SDCCopt.c @@ -770,6 +770,51 @@ replaceRegEqv (eBBlock ** ebbs, int count) } } +/*-----------------------------------------------------------------*/ +/* findReqv - search for a register equivalent */ +/*-----------------------------------------------------------------*/ +operand * +findReqv (symbol * prereqv, eBBlock ** ebbs, int count) +{ + int i; + iCode * ic; + + /* for all blocks do */ + for (i=0; isch; ic; ic = ic->next) + { + if (ic->op == IFX) + { + if (IS_ITEMP (IC_COND (ic)) + && OP_SYMBOL (IC_COND (ic))->prereqv == prereqv) + return IC_COND (ic); + } + else if (ic->op == JUMPTABLE) + { + if (IS_ITEMP (IC_JTCOND (ic)) + && OP_SYMBOL (IC_JTCOND (ic))->prereqv == prereqv) + return IC_JTCOND (ic); + } + else + { + if (IS_ITEMP (IC_LEFT (ic)) + && OP_SYMBOL (IC_LEFT (ic))->prereqv == prereqv) + return IC_LEFT (ic); + if (IS_ITEMP (IC_RIGHT (ic)) + && OP_SYMBOL (IC_RIGHT (ic))->prereqv == prereqv) + return IC_RIGHT (ic); + if (IS_ITEMP (IC_RESULT (ic)) + && OP_SYMBOL (IC_RESULT (ic))->prereqv == prereqv) + return IC_RESULT (ic); + } + } + } + + return NULL; +} + /*-----------------------------------------------------------------*/ /* killDeadCode - eliminates dead assignments */ /*-----------------------------------------------------------------*/ @@ -903,6 +948,29 @@ killDeadCode (eBBlock ** ebbs, int count) /* and defset of the block */ bitVectUnSetBit (ebbs[i]->defSet, ic->key); + /* If this is the last of a register equivalent, */ + /* look for a successor register equivalent. */ + bitVectUnSetBit (OP_DEFS (IC_RESULT (ic)), ic->key); + if (IS_ITEMP (IC_RESULT (ic)) + && OP_SYMBOL (IC_RESULT (ic))->isreqv + && bitVectIsZero (OP_DEFS (IC_RESULT (ic)))) + { + symbol * resultsym = OP_SYMBOL (IC_RESULT (ic)); + symbol * prereqv = resultsym->prereqv; + + if (OP_SYMBOL (prereqv->reqv) == resultsym) + { + operand * newreqv; + + IC_RESULT (ic) = NULL; + newreqv = findReqv (prereqv, ebbs, count); + if (newreqv) + { + prereqv->reqv = newreqv; + } + } + } + /* delete the result */ IC_RESULT (ic) = NULL; diff --git a/src/SDCCpeeph.c b/src/SDCCpeeph.c index ed9e4bdf..a034e34c 100644 --- a/src/SDCCpeeph.c +++ b/src/SDCCpeeph.c @@ -945,6 +945,7 @@ getPeepLine (lineNode ** head, char **bpp) { char lines[MAX_PATTERN_LEN]; char *lp; + int isComment; lineNode *currL = NULL; char *bp = *bpp; @@ -975,18 +976,22 @@ getPeepLine (lineNode ** head, char **bpp) lp = lines; while ((*bp != '\n' && *bp != '}') && *bp) *lp++ = *bp++; - *lp = '\0'; - if (!currL) - *head = currL = newLineNode (lines); - else - currL = connectLine (currL, newLineNode (lines)); - + lp = lines; while (*lp && isspace(*lp)) lp++; - if (*lp==';') - currL->isComment = 1; + isComment = (*lp == ';'); + + if (!isComment || (isComment && !options.noPeepComments)) + { + if (!currL) + *head = currL = newLineNode (lines); + else + currL = connectLine (currL, newLineNode (lines)); + currL->isComment = isComment; + } + } *bpp = bp; @@ -1558,23 +1563,35 @@ replaceRule (lineNode ** shead, lineNode * stail, peepRule * pr) lhead = comment; } - /* determine which iCodes the replacment lines relate to */ - reassociate_ic(*shead,stail,lhead,cl); - - /* now we need to connect / replace the original chain */ - /* if there is a prev then change it */ - if ((*shead)->prev) + if (lhead) { - (*shead)->prev->next = lhead; - lhead->prev = (*shead)->prev; + /* determine which iCodes the replacment lines relate to */ + reassociate_ic(*shead,stail,lhead,cl); + + /* now we need to connect / replace the original chain */ + /* if there is a prev then change it */ + if ((*shead)->prev) + { + (*shead)->prev->next = lhead; + lhead->prev = (*shead)->prev; + } + *shead = lhead; + /* now for the tail */ + if (stail && stail->next) + { + stail->next->prev = cl; + if (cl) + cl->next = stail->next; + } } - *shead = lhead; - /* now for the tail */ - if (stail && stail->next) + else { - stail->next->prev = cl; - if (cl) - cl->next = stail->next; + /* the replacement is empty - delete the source lines */ + if ((*shead)->prev) + (*shead)->prev->next = stail->next; + if (stail->next) + stail->next->prev = (*shead)->prev; + *shead = stail->next; } } diff --git a/src/hc08/main.c b/src/hc08/main.c index c25636b2..16761b6e 100644 --- a/src/hc08/main.c +++ b/src/hc08/main.c @@ -128,6 +128,7 @@ _hc08_finaliseOptions (void) port->mem.default_globl_map = data; } + istack->ptrType = FPOINTER; } static void diff --git a/src/hc08/ralloc.c b/src/hc08/ralloc.c index e3269f72..cec247d7 100644 --- a/src/hc08/ralloc.c +++ b/src/hc08/ralloc.c @@ -1739,10 +1739,10 @@ regTypeNum (eBBlock *ebbs) (ic = hTabItemWithKey (iCodehTab, bitVectFirstBit (sym->defs))) && POINTER_GET (ic) && - !IS_BITVAR (sym->etype)) + !IS_BITVAR (sym->etype) && + (aggrToPtrDclType (operandType (IC_LEFT (ic)), FALSE) == POINTER)) { - if (ptrPseudoSymSafe (sym, ic)) { ptrPseudoSymConvert (sym, ic, rematStr (OP_SYMBOL (IC_LEFT (ic))));