From: slade_rich Date: Thu, 9 Sep 2004 02:13:05 +0000 (+0000) Subject: Copy C code comments to optimised replacement code. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=b4262b8ddb85cfb094c77674cbcaaa0089b4ad70;p=fw%2Fsdcc Copy C code comments to optimised replacement code. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3484 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/pic/pcode.c b/src/pic/pcode.c index 8cdbf6b9..33eb3d72 100644 --- a/src/pic/pcode.c +++ b/src/pic/pcode.c @@ -75,7 +75,7 @@ static pFile *the_pFile = NULL; static pBlock *pb_dead_pcodes = NULL; /* Hardcoded flags to change the behavior of the PIC port */ -static int peepOptimizing = 0; /* run the peephole optimizer if nonzero */ +static int peepOptimizing = 1; /* run the peephole optimizer if nonzero */ static int functionInlining = 1; /* inline functions if nonzero */ int debug_verbose = 0; /* Set true to inundate .asm file */ diff --git a/src/pic/pcodepeep.c b/src/pic/pcodepeep.c index 7b0d7c80..902178d0 100644 --- a/src/pic/pcodepeep.c +++ b/src/pic/pcodepeep.c @@ -1993,7 +1993,7 @@ int pCodePeepMatchRule(pCode *pc) if(matched) { pCode *pcprev; - pCode *pcr; + pCode *pcr, *pcout; /* We matched a rule! Now we have to go through and remove the @@ -2011,6 +2011,7 @@ int pCodePeepMatchRule(pCode *pc) /* Unlink the original code */ + pcout = pc; pcprev = pc->prev; pcprev->next = pcin; if(pcin) @@ -2087,8 +2088,7 @@ int pCodePeepMatchRule(pCode *pc) } else if (pcr->type == PC_COMMENT) { pCodeInsertAfter(pc, newpCodeCharP( ((pCodeComment *)(pcr))->comment)); } - - + pc = pc->next; #ifdef PCODE_DEBUG DFPRINTF((stderr," NEW Code:")); @@ -2108,12 +2108,27 @@ int pCodePeepMatchRule(pCode *pc) } + /* Copy C code comments to new code. */ + pc = pcprev->next; + if (pc) { + for (; pcout!=pcin; pcout=pcout->next) { + if (pcout->type==PC_OPCODE && PCI(pcout)->cline) { + while (pc->type!=PC_OPCODE || PCI(pc)->cline) { + pc = pc->next; + if (!pc) + break; + } + PCI(pc)->cline = PCI(pcout)->cline; + } + } + } + return 1; - } + } next_rule: - peeprules = peeprules->next; - } - DFPRINTF((stderr," no rule matched\n")); + peeprules = peeprules->next; + } + DFPRINTF((stderr," no rule matched\n")); - return 0; + return 0; }