]> git.gag.com Git - fw/sdcc/commitdiff
* device/include/mcs51/c8051f020.h,
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 3 Nov 2006 09:11:47 +0000 (09:11 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 3 Nov 2006 09:11:47 +0000 (09:11 +0000)
* device/include/mcs51/c8051f040.h,
* device/include/mcs51/c8051f060.h,
* device/include/mcs51/c8051f120.h: added PS0, fixed bug 1589279
* src/z80/gen.c (gencjneshort),
* src/z80/peeph.def: applied patch 1571373, thanks Philipp Krause

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

ChangeLog
device/include/mcs51/c8051f020.h
device/include/mcs51/c8051f040.h
device/include/mcs51/c8051f060.h
device/include/mcs51/c8051f120.h
src/z80/gen.c
src/z80/peeph.def

index 05a9532edb20579de2632cb54222b776e40bc883..f5d7807bedc2d376b90c658c11b133a2df1af549 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-11-03 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * device/include/mcs51/c8051f020.h,
+       * device/include/mcs51/c8051f040.h,
+       * device/include/mcs51/c8051f060.h,
+       * device/include/mcs51/c8051f120.h: added PS0, fixed bug 1589279
+       * src/z80/gen.c (gencjneshort),
+       * src/z80/peeph.def: applied patch 1571373, thanks Philipp Krause
+
 2006-10-31 Borut Razem <borut.razem AT siol.net>
 
        * debugger/mcs51/acinclude.m4, debugger/mcs51/aclocal.m4,
index cec6e9b391dc257d94cd6942ffdc5cedbd722487..58326c157a115a43129d8d86b15cd8f543248e21 100644 (file)
@@ -244,8 +244,8 @@ __sbit __at (0xA8) EX0         ;  /* EXTERNAL INTERRUPT 0 ENABLE
 __sbit __at (0xA9) ET0         ;  /* TIMER 0 INTERRUPT ENABLE                                */
 __sbit __at (0xAA) EX1         ;  /* EXTERNAL INTERRUPT 1 ENABLE                             */
 __sbit __at (0xAB) ET1         ;  /* TIMER 1 INTERRUPT ENABLE                                */
-__sbit __at (0xAC) ES          ;  /* SERIAL PORT 0 INTERRUPT ENABLE                          */
 __sbit __at (0xAC) ES0         ;  /* SERIAL PORT 0 INTERRUPT ENABLE                          */
+__sbit __at (0xAC) ES          ;  /* SERIAL PORT 0 INTERRUPT ENABLE                          */
 __sbit __at (0xAD) ET2         ;  /* TIMER 2 INTERRUPT ENABLE                                */
 __sbit __at (0xAF) EA          ;  /* GLOBAL INTERRUPT ENABLE                                 */
 
@@ -264,6 +264,7 @@ __sbit __at (0xB8) PX0         ;  /* EXTERNAL INTERRUPT 0 PRIORITY
 __sbit __at (0xB9) PT0         ;  /* TIMER 0 PRIORITY                                        */
 __sbit __at (0xBA) PX1         ;  /* EXTERNAL INTERRUPT 1 PRIORITY                           */
 __sbit __at (0xBB) PT1         ;  /* TIMER 1 PRIORITY                                        */
+__sbit __at (0xBC) PS0         ;  /* SERIAL PORT PRIORITY                                    */
 __sbit __at (0xBC) PS          ;  /* SERIAL PORT PRIORITY                                    */
 __sbit __at (0xBD) PT2         ;  /* TIMER 2 PRIORITY                                        */
 
index 67388dacb61c9e296dbeff04792f7c582460ff28..2885a00636a317ad8f72ab57d407ad76a354c9fd 100644 (file)
@@ -194,6 +194,9 @@ __sfr __at 0xE4 XBR3     ;  /* CROSSBAR CONFIGURATION REGISTER 3             */
 __sfr __at 0xE8 P6       ;  /* PORT 6                                        */
 __sfr __at 0xF8 P7       ;  /* PORT 7                                        */
 
+/*
+Do NOT use sfr16 for CAN0DAT !
+*/
 
 /*  BIT Registers  */
 
@@ -314,6 +317,7 @@ __sbit __at 0xB8 PX0     ;  /* EXTERNAL INTERRUPT 0 PRIORITY                 */
 __sbit __at 0xB9 PT0     ;  /* TIMER 0 PRIORITY                              */
 __sbit __at 0xBA PX1     ;  /* EXTERNAL INTERRUPT 1 PRIORITY                 */
 __sbit __at 0xBB PT1     ;  /* TIMER 1 PRIORITY                              */
+__sbit __at 0xBC PS0     ;  /* SERIAL PORT PRIORITY                          */
 __sbit __at 0xBC PS      ;  /* SERIAL PORT PRIORITY                          */
 __sbit __at 0xBD PT2     ;  /* TIMER 2 PRIORITY                              */
 
index 0835a6c3e8352d98fa19296f3fc7c5db64a067b6..a366e94f13aec0b3350ac4042ff10f513abd77e4 100644 (file)
@@ -335,6 +335,7 @@ __sbit __at 0xB8 PX0     ;  /* EXTERNAL INTERRUPT 0 PRIORITY                 */
 __sbit __at 0xB9 PT0     ;  /* TIMER 0 PRIORITY                              */
 __sbit __at 0xBA PX1     ;  /* EXTERNAL INTERRUPT 1 PRIORITY                 */
 __sbit __at 0xBB PT1     ;  /* TIMER 1 PRIORITY                              */
+__sbit __at 0xBC PS0     ;  /* SERIAL PORT PRIORITY                          */
 __sbit __at 0xBC PS      ;  /* SERIAL PORT PRIORITY                          */
 __sbit __at 0xBD PT2     ;  /* TIMER 2 PRIORITY                              */
 
index 661ac9546c76d117badd1f4a5d155d583479739f..dc53b8bb15d1d0bcb49812d0f9e66cb6d1ed3a6f 100644 (file)
@@ -352,6 +352,7 @@ __sbit __at (0xB8) PX0             ;  /* EXTERNAL INTERRUPT 0 PRIORITY
 __sbit __at (0xB9) PT0             ;  /* TIMER 0 PRIORITY                              */
 __sbit __at (0xBA) PX1             ;  /* EXTERNAL INTERRUPT 1 PRIORITY                 */
 __sbit __at (0xBB) PT1             ;  /* TIMER 1 PRIORITY                              */
+__sbit __at (0xBC) PS0             ;  /* SERIAL PORT PRIORITY                          */
 __sbit __at (0xBC) PS              ;  /* SERIAL PORT PRIORITY                          */
 __sbit __at (0xBD) PT2             ;  /* TIMER 2 PRIORITY                              */
 
index 527f3c1e91b359e4ff06ad1613b651646895ff5a..d2d02ba740cd46451b841ea5f523ddf1a7fa1812 100644 (file)
@@ -4779,11 +4779,11 @@ gencjneshort (operand * left, operand * right, symbol * lbl)
         {
           while (size--)
             {
-              emit2 ("ld a,%s", aopGet (AOP (left), offset, FALSE));
-              if ((AOP_TYPE (right) == AOP_LIT) && lit == 0)
+              _moveA (aopGet (AOP (left), offset, FALSE));
+              if ((unsigned int) ((lit >> (offset * 8)) & 0x0FFL) == 0)
                 emit2 ("or a,a");
               else
-                emit2 ("cp a,%s", aopGet (AOP (right), offset, FALSE));
+                emit2 ("sub a,%s", aopGet (AOP (right), offset, FALSE));
               emit2 ("jp NZ,!tlabel", lbl->key + 100);
               offset++;
             }
@@ -4798,13 +4798,18 @@ gencjneshort (operand * left, operand * right, symbol * lbl)
       while (size--)
         {
           _moveA (aopGet (AOP (left), offset, FALSE));
-          if ((AOP_TYPE (left) == AOP_DIR && AOP_TYPE (right) == AOP_LIT) &&
+          if (/*AOP_TYPE (left) == AOP_DIR &&*/ AOP_TYPE (right) == AOP_LIT &&
               ((unsigned int) ((lit >> (offset * 8)) & 0x0FFL) == 0))
-            /* PENDING */
-            emit2 ("jp NZ,!tlabel", lbl->key + 100);
+            {
+              /* PENDING */
+              /* MB: pending what? doesn't this need "or a,a"? */
+              /* and I don't think AOP_TYPE(left) has anything to do with this */
+              emit2 ("or a,a");
+              emit2 ("jp NZ,!tlabel", lbl->key + 100);
+            }
           else
             {
-              emit2 ("cp %s", aopGet (AOP (right), offset, FALSE));
+              emit2 ("sub %s", aopGet (AOP (right), offset, FALSE));
               emit2 ("jp NZ,!tlabel", lbl->key + 100);
             }
           offset++;
index d94ffdd20092edb75796217c975bf3a8adb29516..2fb852b6461d820edfef25446ea3d4ea6792e3b2 100644 (file)
@@ -3,11 +3,13 @@ replace {
 } by {
        ERROR - peephole - caught (hl),(hl)
 }
+
 replace restart {
        ld      %1,%1
 } by {
-       ; Removed redundent load
+       ; peephole removed redundant load.
 }
+
 replace restart {
        xor     a,a
        or      a,%1
@@ -18,13 +20,7 @@ replace restart {
        or      a,%1
        jp      %2,%3
 }
-replace restart {
-       cp      a,#0x00
-       jp      NZ,%1
-} by {
-       or      a,a
-       jp      NZ,%1
-}
+
 replace restart {
        jp      NZ,%1
        jp      %2
@@ -36,7 +32,8 @@ replace restart {
 %1:
        jp      %3
 %2:
-}
+} if labelRefCountChange(%1 -1)
+
 replace restart {
        jp      NZ,%1
        jp      %2
@@ -44,7 +41,8 @@ replace restart {
 } by {
        jp      Z,%2
 %1:
-}
+} if labelRefCountChange(%1 -1)
+
 replace restart {
        jp      Z,%1
        jp      %2
@@ -52,19 +50,22 @@ replace restart {
 } by {
        jp      NZ,%2
 %1:
-}
+} if labelRefCountChange(%1 -1)
+
 replace restart {
        or      a,%1
        or      a,a
 } by {
        or      a,%1
 }
+
 replace restart {
        or      a,%1)
        or      a,a
 } by {
        or      a,%1)
 }
+
 replace restart {
        xor     a,a
        or      a,%1
@@ -79,6 +80,7 @@ replace restart {
        or      a,%3
        jp      Z,%2
 }
+
 replace restart {
        jp      NZ,%1
        inc     %3)
@@ -89,37 +91,43 @@ replace restart {
        inc     %3)
 %1:
        jp      %2
-}
+} if labelRefCountChange(%1 -1), labelRefCountChange(%2 1)
+
 replace restart {
        xor     a,a
        ld      a,#0x00
 } by {
        xor     a,a
 }
+
 replace {
        ld      e,#0x00
        ld      d,#0x00
 } by {
        ld      de,#0x0000
 }
+
 replace {
        ld      l,#0x00
        ld      h,#0x00
 } by {
        ld      hl,#0x0000
 }
+
 replace {
        ld      c,#0x00
        ld      b,#0x00
 } by {
        ld      bc,#0x0000
 }
+
 replace restart {
        ld      %1,a
        ld      a,%1
 } by {
        ld      %1,a
 } if notVolatile %1
+
 replace restart {
        jp      %1,%2
        jr      %3
@@ -130,7 +138,8 @@ replace restart {
        jr      %3
 %2:
        jp      %4
-}
+} if labelRefCountChange(%2 -1), labelRefCountChange(%4 1)
+
 replace {
        ld      l,e
        ld      h,d
@@ -142,12 +151,14 @@ replace {
        push    de
        push    bc
 }
+
 replace {
        and     a,#%1
        or      a,a
 } by {
        and     a,#%1
 }
+
 replace {
        ld      b,l
        ld      a,b
@@ -158,6 +169,7 @@ replace {
        pop     bc
        ld      b,a
 }
+
 replace {
        ld      d,l
        ld      a,d
@@ -168,6 +180,7 @@ replace {
        pop     de
        ld      d,a
 }
+
 replace {
        ld      a,b
        push    af
@@ -176,6 +189,7 @@ replace {
        push    bc
        inc     sp
 }
+
 replace {
        ld      a,d
        push    af
@@ -184,6 +198,7 @@ replace {
        push    de
        inc     sp
 }
+
 replace {
        ld      a,%1
        sub     a,#%2
@@ -198,6 +213,7 @@ replace {
        cp      a,#%4
        jp      P,%5
 }
+
 replace {
        ld      e,l
        ld      d,h
@@ -207,6 +223,7 @@ replace {
        ld      e,l
        ld      d,h
 }
+
 replace {
        ld      %1,%2
        ld      %3,%4
@@ -217,3 +234,231 @@ replace {
        ld      %3,%4
 }
 
+// From: Philipp Klaus Krause
+replace restart {
+       ld      %1,a
+       ld      a,%2
+       add     a,%1
+       ld      %1,a
+} by {
+       ; peephole removed loads by exploiting commutativity of addition.
+       add     a,%2
+       ld      %1,a
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+       ld      %1,a
+       ld      a,%2
+       add     a,%1
+} by {
+       ld      %1, a
+       ; peephole removed load by exploiting commutativity of addition.
+       add     a, %2
+}
+
+// From: Philipp Klaus Krause
+replace {
+       or      a,%1
+       jp      NZ,%2
+       ld      %3,#0x00
+} by {
+       or      a,%1
+       jp      NZ,%2
+       ld      %3,a
+       ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+       and     a,%1
+       jp      NZ,%2
+       ld      %3,#0x00
+} by {
+       and     a,%1
+       jp      NZ,%2
+       ld      %3,a
+       ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+       sub     a,%1
+       jp      NZ,%2
+       ld      %3,#0x00
+} by {
+       sub     a,%1
+       jp      NZ,%2
+       ld      %3,a
+       ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+       dec     a
+       jp      NZ,%1
+       ld      %2,#0x00
+} by {
+       dec     a
+       jp      NZ,%1
+       ld      %2,a
+       ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+       or      a,%1
+       jp      NZ,%2
+       ld      a,%3
+       or      a,a
+} by {
+       or      a,%1
+       jp      NZ,%2
+       or      a,%3
+       ; peephole shortened or using a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+       and     a,%1
+       jp      NZ,%2
+       ld      a,%3
+       or      a,a
+} by {
+       and     a,%1
+       jp      NZ,%2
+       or      a,%3
+       ; peephole shortened or using a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+       sub     a,%1
+       jp      NZ,%2
+       ld      a,%3
+       or      a,a
+} by {
+       sub     a,%1
+       jp      NZ,%2
+       or      a,%3
+       ; peephole shortened or using a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace {
+       dec     a
+       jp      NZ,%1
+       ld      a,%2
+       or      a,a
+} by {
+       dec     a
+       jp      NZ,%1
+       or      a,%2
+       ; peephole shortened or using a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+       or      a,%1
+       jp      NZ,%2
+       push    %3
+       ld      %4,#0x00
+} by {
+       or      a,%1
+       jp      NZ,%2
+       push    %3
+       ld      %4,a
+       ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+       and     a,%1
+       jp      NZ,%2
+       push    %3
+       ld      %4,#0x00
+} by {
+       sub     a,%1
+       jp      NZ,%2
+       push    %3
+       ld      %4,a
+       ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+       sub     a,%1
+       jp      NZ,%2
+       push    %3
+       ld      %4,#0x00
+} by {
+       sub     a,%1
+       jp      NZ,%2
+       push    %3
+       ld      %4,a
+       ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart {
+       dec     a
+       jp      NZ,%1
+       push    %2
+       ld      %3,#0x00
+} by {
+       dec     a
+       jp      NZ,%1
+       push    %2
+       ld      %3,a
+       ; peephole replaced constant #0x00 by a (which has just been tested to be #0x00).
+}
+
+// From: Philipp Klaus Krause
+replace restart{
+       jp      NZ,%1
+       or      a,%2
+       jp      Z,%3
+%1:
+       jp      %4
+%3:
+} by {
+       jp      NZ,%4
+       ; peephole redirected jump
+       or      a,%2
+       jp      NZ,%4
+       ; peephole redirected jump
+%3:
+} if labelRefCount(%1 1), labelRefCountChange(%1 -1), labelRefCountChange(%3 -1), labelRefCountChange(%4 1)
+
+// Should be one of the last ones. Opens the code to further peephole optimization.
+// From: Philipp Klaus Krause
+replace restart {
+%1:
+} by {
+       ; peephole removed unused label %1.
+} if labelRefCount(%1 0)
+
+// From: Philipp Klaus Krause
+replace {
+       jp      Z,%5
+} by {
+       jr      Z,%5
+} if labelInRange()
+
+replace {
+       jp      NZ,%5
+} by {
+       jr      NZ,%5
+} if labelInRange()
+
+replace {
+       jp      C,%5
+} by {
+       jr      C,%5
+} if labelInRange()
+
+replace {
+       jp      NC,%5
+} by {
+       jr      NC,%5
+} if labelInRange()