* src/SDCCpeeph.c (replaceRule): support empty replacement peephole
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 24 Apr 2004 07:06:41 +0000 (07:06 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 24 Apr 2004 07:06:41 +0000 (07:06 +0000)
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

ChangeLog
src/SDCCcse.c
src/SDCCglobl.h
src/SDCCmain.c
src/SDCCmem.c
src/SDCCopt.c
src/SDCCpeeph.c
src/hc08/main.c
src/hc08/ralloc.c

index edb3d273ab31b6e2fa31f45dc73c570703c0a0fd..337252645af378ec1717da4d8c7923ec8c87807c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2004-04-24 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * 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 <epetrich AT ivorytower.norman.ok.us>
 
        * src/SDCCsymt.h: a missing part of my last change
index 1466760c72dc7b058d4fc612e4cbeb1008649b9e..c57509201370e3d868ad059ec95cfe12ba7293a5 100644 (file)
@@ -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;
                }
        }
 }
index 687d9075c624e46723ab77f4f8eb72f389364b0c..3643e5f4b063423fe97673dcee93862d9f09d47b 100644 (file)
@@ -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 */
index fb8cfa76d50d2e03952464f695d02c46a31d757a..3231e34c047ce37bfe4d25821df58926b9eea28b 100644 (file)
@@ -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"},
index ba185d241e3da2d5a2e5e95dcc43c705040ada54..dc0982b44137381faf5189e571f0a864e171194a 100644 (file)
@@ -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 */
index cfb416d92d94f93501404ec6cb7c01f54276f4b8..4e9c2a7be560647efde1841a42b6a0a9efcf780c 100644 (file)
@@ -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; i<count; i++)
+    {
+      /* for all instructions in the block do */
+      for (ic = ebbs[i]->sch; 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;
                  
index ed9e4bdfabb86db89a82dc774bb4378841eb14b7..a034e34c1365c7b7b2b163a57c97771c5b31c628 100644 (file)
@@ -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;
     }
 }
 
index c25636b2f71957b7f4d6b5775371c829bbf47232..16761b6ebdf744bc2de62629f724b7db60c7b4af 100644 (file)
@@ -128,6 +128,7 @@ _hc08_finaliseOptions (void)
       port->mem.default_globl_map = data;
     }
 
+  istack->ptrType = FPOINTER;
 }
 
 static void
index e3269f72e8710c3d13b49a123c74a4b0e60e5da2..cec247d7b7a602ddb416e71028bf76c4a87dd213 100644 (file)
@@ -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))));