]> git.gag.com Git - fw/sdcc/commitdiff
* src/SDCCpeeph.c (operandsLiteral): new, added,
authormaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 29 Mar 2006 07:21:04 +0000 (07:21 +0000)
committermaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 29 Mar 2006 07:21:04 +0000 (07:21 +0000)
  (callFuncByName): inserted operandsLiteral
* src/mcs51/peeph.def: reenabled 132.e, added extra check to 132.x

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4076 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCpeeph.c
src/mcs51/peeph.def

index d8ffe22847371ce2ea992e6046824ceaa9feac12..794f4876176a9d34dc05eaa96beaf824519aca4e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,15 @@
+2006-03-29 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/SDCCpeeph.c (operandsLiteral): new, added,
+         (callFuncByName): inserted operandsLiteral
+       * src/mcs51/peeph.def: reenabled 132.e, added extra check to 132.x
+
 2006-03-28 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
 
        * doc/sdccman.lyx: added paragraph "Use of SDCC in Education"
        * src/mcs51/peeph.def: disabled rule 132.e fixing bug #1453093
 
-2006-03-23 Maarten Brock <sourceforge.brock AT dse.nl>
+2006-03-24 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/z80/gen.c (genFunction, genEndFunction): fixed bug 1160666,
          implemented patch 1120823 Thanks to Willy De la Court (normal
index b227cf0a0a9cd5a52c6865dd66d06dfc6240cd2c..478178c6675cd4148b36b14f5d80c539195a06d9 100644 (file)
@@ -963,6 +963,39 @@ FBYNAME (operandsNotRelated)
 }
 
 
+/*-------------------------------------------------------------------*/
+/* operandsLiteral - returns true of the condition's operands are    */
+/* literals.                                                         */
+/*-------------------------------------------------------------------*/
+FBYNAME (operandsLiteral)
+{
+  set *operands;
+  const char *op;
+
+  operands = setFromConditionArgs (cmdLine, vars);
+
+  if (!operands)
+    {
+      fprintf (stderr,
+               "*** internal error: operandsLiteral peephole restriction"
+               " malformed: %s\n", cmdLine);
+      return FALSE;
+    }
+
+  for (op = setFirstItem (operands); op; op = setNextItem (operands))
+    {
+      if (!isdigit(*op))
+        {
+          deleteSet (&operands);
+          return FALSE;
+        }
+    }
+
+  deleteSet (&operands);
+  return TRUE;
+}
+
+
 /*-----------------------------------------------------------------*/
 /* callFuncByName - calls a function as defined in the table       */
 /*-----------------------------------------------------------------*/
@@ -1046,6 +1079,9 @@ callFuncByName (char *fname,
     {
       "operandsNotRelated", operandsNotRelated
     },
+    {
+      "operandsLiteral", operandsLiteral
+    },
     {
       "labelRefCountChange", labelRefCountChange
     }
index aff964cca292a17405c7f484eb58b8d85b9de2dc..e0aed8b39b97174867b308a546b1476aa1295a64 100644 (file)
@@ -684,7 +684,7 @@ replace {
        mov     a,%2
        add     a,#0xff - %1
        mov     %3,c
-}
+} if operandsLiteral(%1)
 
 replace {
        clr     c
@@ -696,7 +696,7 @@ replace {
        mov     a,%2
        add     a,#0xff - %1
        jnc     %5
-}
+} if operandsLiteral(%1)
 
 replace {
        clr     c
@@ -708,7 +708,7 @@ replace {
        mov     a,%2
        add     a,#0xff - %1
        jc      %5
-}
+} if operandsLiteral(%1)
 
 replace {
        clr     c
@@ -720,20 +720,19 @@ replace {
        mov     a,#0x100 - %2
        add     a,%1
        mov     %3,c
-} if operandsNotRelated('0x00' %2)
+} if operandsNotRelated('0x00' %2), operandsLiteral(%2)
 
-//This peephole caused bug #1453093
-//replace {
-//     clr     c
-//     mov     a,%1
-//     subb    a,#%2
-//     jnc     %5
-//} by {
-//     ;       Peephole 132.e  optimized genCmpLt by inverse logic (carry differs)
-//     mov     a,#0x100 - %2
-//     add     a,%1
-//     jc      %5
-//} if operandsNotRelated('0x00' %2)
+replace {
+       clr     c
+       mov     a,%1
+       subb    a,#%2
+       jnc     %5
+} by {
+       ;       Peephole 132.e  optimized genCmpLt by inverse logic (carry differs)
+       mov     a,#0x100 - %2
+       add     a,%1
+       jc      %5
+} if operandsNotRelated('0x00' %2), operandsLiteral(%2)
 
 replace {
        clr     c
@@ -745,7 +744,7 @@ replace {
        mov     a,#0x100 - %2
        add     a,%1
        jnc     %5
-} if operandsNotRelated('0x00' %2)
+} if operandsNotRelated('0x00' %2), operandsLiteral(%2)
 
 
 replace {