Implemented generic part of RFE #1880202
authorspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 19 Apr 2008 12:06:38 +0000 (12:06 +0000)
committerspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 19 Apr 2008 12:06:38 +0000 (12:06 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5138 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCpeeph.c
src/mcs51/main.c
src/port.h

index 7a1f3f258f5531de16371a58fd1f0e28f986a412..075cad2abc12af5ba428411386de4a84553bac5b 100644 (file)
@@ -402,6 +402,28 @@ FBYNAME (deadMove)
   return FALSE;
 }
 
+/*-----------------------------------------------------------------*/
+/* notUsed - Check, if value in register is not read again         */
+/*-----------------------------------------------------------------*/
+FBYNAME (notUsed)
+{
+  const char *what;
+
+  if(cmdLine[0] != '\'')
+    what = hTabItemWithKey (vars, 1);
+  else
+  {
+    cmdLine[strlen(cmdLine) - 1] = 0;
+    what = cmdLine + 1;
+  }
+
+  if (port->peep.notUsed)
+    return port->peep.notUsed (what, endPl, head);
+
+  fprintf (stderr, "Function notUsed not initialized in port structure\n");
+  return FALSE;
+}
+
 /*-----------------------------------------------------------------*/
 /* operandsNotSame - check if %1 & %2 are the same                 */
 /*-----------------------------------------------------------------*/
@@ -1200,6 +1222,9 @@ ftab[] =                                // sorted on the number of times used
   },
   {
     "useAcallAjmp", useAcallAjmp
+  },
+  {
+    "notUsed", notUsed
   }
 };
 /*-----------------------------------------------------------------*/
index eeef4b25aecb83a377a4e42ba084d3086cb50c0f..1904e14985be2f24c48be2c669994a6a45c06739 100644 (file)
@@ -8,6 +8,7 @@
 #include "main.h"
 #include "ralloc.h"
 #include "gen.h"
+#include "peep.h"
 #include "dbuf_string.h"
 #include "../SDCCutil.h"
 
@@ -723,7 +724,7 @@ PORT mcs51_port =
     MODEL_SMALL | MODEL_MEDIUM | MODEL_LARGE,
     MODEL_SMALL
   },
-  {
+  {                             /* Assembler */
     _asmCmd,
     NULL,
     "-plosgffc",                /* Options with debug */
@@ -732,19 +733,20 @@ PORT mcs51_port =
     ".asm",
     NULL                        /* no do_assemble function */
   },
-  {
+  {                             /* Linker */
     _linkCmd,
     NULL,
     NULL,
     ".rel",
     1
   },
-  {
+  {                             /* Peephole optimizer */
     _defaultRules,
     getInstructionSize,
     getRegsRead,
     getRegsWritten,
-    mcs51DeadMove
+    mcs51DeadMove,
+    0
   },
   {
     /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
index fd32518bf9da274a454b3494b2a67903a0fcb47d..3363aa680042d8277bfd38452336008ca0fe8e5d 100644 (file)
@@ -9,7 +9,6 @@
 #include "SDCCargs.h"
 #include "SDCCpeeph.h"
 #include "dbuf.h"
-#include "mcs51/peep.h"
 
 #define TARGET_ID_MCS51    1
 #define TARGET_ID_GBZ80    2
@@ -136,6 +135,7 @@ typedef struct
         bitVect * (*getRegsRead)(lineNode *line);
         bitVect * (*getRegsWritten)(lineNode *line);
         bool (*deadMove) (const char *reg, lineNode *currPl, lineNode *head);
+        bool (*notUsed) (const char *reg, lineNode *currPl, lineNode *head);
       }
     peep;