Copy C code comments to optimised replacement code.
authorslade_rich <slade_rich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 9 Sep 2004 02:13:05 +0000 (02:13 +0000)
committerslade_rich <slade_rich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 9 Sep 2004 02:13:05 +0000 (02:13 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3484 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/pic/pcode.c
src/pic/pcodepeep.c

index 8cdbf6b9d888d1bda89696bd5ecd8b8f650ddabe..33eb3d723ec69a3327fdb47f6a9a81f3d83eee8c 100644 (file)
@@ -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 */
 
index 7b0d7c801d1b3768cdca87edca13b0e688f72e0c..902178d0fb05a9e609b51a307b4cc743faae8f6d 100644 (file)
@@ -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;
 }