]> git.gag.com Git - fw/sdcc/blobdiff - src/mcs51/peeph.def
Try to make the peephole optimizer smarter by maintaining
[fw/sdcc] / src / mcs51 / peeph.def
index 5ceb19bcb4c5db2f5b4f6cf9d452227662c06677..518dd7967c1b8d8734a5fc570c3913e3c14a1206 100644 (file)
@@ -67,7 +67,8 @@ replace {
         mov     %1,a
         mov     dptr,#%2
         movx    @dptr,a
-}
+} if notVolatile %1
+
 replace {
         mov     a,acc
 } by {
@@ -86,7 +87,7 @@ replace {
         movx    @dptr,a
         inc     dptr
         movx    @dptr,a
-}
+} if notVolatile %1
 
 replace {
         mov     %1,%2
@@ -108,7 +109,7 @@ replace {
 %7:
         mov     sp,bp
         pop     bp
-}
+} if notVolatile %1
 
 replace {
         mov     %1,%2
@@ -149,7 +150,7 @@ replace {
 } by {
         ;       Peephole 105    removed redundant mov
         mov     %1,a
-}
+} if notVolatile %1
 
 replace {
         mov     %1,a
@@ -159,7 +160,7 @@ replace {
         ;       Peephole 106    removed redundant mov 
         mov     %1,a
         clr     c
-}
+} if notVolatile %1
 
 replace {
         ljmp    %1
@@ -520,7 +521,7 @@ replace {
         mov     r%1,%2
         inc     @r%1
         mov     ar%3,@r%1
-}
+} if notVolatile
 
 replace {
         mov     r%1,%2
@@ -533,7 +534,7 @@ replace {
         mov     r%1,%2
         dec     @r%1
         mov     ar%3,@r%1
-}
+} if notVolatile
 
 replace {
         mov     r%1,a
@@ -555,7 +556,7 @@ replace {
         mov     %1,a
         mov     dpl,%2
         mov     dph,%3
-}
+} if notVolatile %1
 
 // WTF? Doesn't look sensible to me...
 //replace {
@@ -883,7 +884,7 @@ replace {
         ;       Peephole 166    removed redundant mov
         mov     %1,%2
         mov     %3,%1
-}
+} if notVolatile %1 %2
 
 replace {
         mov     c,%1
@@ -1005,16 +1006,16 @@ replace {
         ;       Peephole 176    optimized increment, removed redundant mov
         inc     @r%2
         mov     %1,@r%2
-}
+} if notVolatile
 
 // this one will screw assignes to volatile/sfr's
-//replace {
-//        mov  %1,%2
-//        mov  %2,%1
-//} by {
-//        ;       Peephole 177   removed redundant mov
-//        mov  %1,%2
-//}
+replace {
+        mov  %1,%2
+        mov  %2,%1
+} by {
+        ;       Peephole 177   removed redundant mov
+        mov  %1,%2
+} if notVolatile %1 %2
 
 // applies to f.e. scott-add.asm (--model-large)
 replace {
@@ -1129,7 +1130,7 @@ replace {
         ;       Peephole 184    removed redundant mov
         cpl     a
         mov     %1,a
-}
+} if notVolatile %1
 
 replace {
 // acc being incremented might cause problems
@@ -1139,7 +1140,7 @@ replace {
         ;       Peephole 185    changed order of increment (acc incremented also!)
         inc     a
         mov     %1,a
-}
+} if notVolatile %1
 
 replace {
         add     a,#%1
@@ -1262,7 +1263,7 @@ replace {
         mov     dptr,%2
         movc    a,@a+dptr
         mov     %1,a
-}
+} if notVolatile %1
 
 replace {
         anl     a,#0x0f
@@ -1273,7 +1274,7 @@ replace {
         ;       Peephole 189    removed redundant mov and anl
         anl     a,#0x0f
         mov     %1,a
-}
+} if notVolatile %1
 
 // rules 190 & 191 need to be in order
 replace {
@@ -1284,7 +1285,7 @@ replace {
         ;       Peephole 190    removed redundant mov
         mov     a,%1
         lcall   __gptrput
-}
+} if notVolatile %1
 
 replace {
         mov     %1,a
@@ -1298,7 +1299,7 @@ replace {
         mov     dpl,%2
         mov     dph,%3
         mov     b,%4
-}
+} if notVolatile %1
 
 replace {
         mov     r%1,a
@@ -1593,7 +1594,7 @@ replace {
         ;       Peephole 204    removed redundant mov
         add     a,acc
         mov     %1,a
-}
+} if notVolatile %1
 
 replace {
         djnz    %1,%2
@@ -1612,7 +1613,7 @@ replace {
         mov     %1,%1
 } by {
         ;       Peephole 206    removed redundant mov %1,%1
-}
+} if notVolatile
 
 replace {
         mov     a,_bp
@@ -1683,6 +1684,7 @@ replace {
         xrl     %1,#0x80
 }
 
+
 replace  {
         mov     %1,a
         mov     a,%2
@@ -1818,13 +1820,13 @@ replace {
         mov     %1 + %2,(%2 + %1)
 } by {
         ;       Peephole 221.a  remove redundant move
-}
+} if notVolatile
 
 replace {
         mov     (%1 + %2 + %3),((%2 + %1) + %3)
 } by {
         ;       Peephole 221.b  remove redundant move
-}
+} if notVolatile
 
 replace {
         dec     r%1
@@ -1842,7 +1844,7 @@ replace {
         ;       Peephole 223    removed redundant dph/dpl moves
         mov     %1,dpl
         mov     %2,dph
-}
+} if notVolatile %1 %2
 
 replace {
         mov     %1,dpl
@@ -1853,7 +1855,7 @@ replace {
         ;       Peephole 224    removed redundant dph/dpl moves
         mov     %1,dpl
         mov     (%1 + 1),dph
-}
+} if notVolatile %1
 
 replace {
         mov     a,%1
@@ -1869,7 +1871,7 @@ replace {
         mov     dpl,%2
         mov     dph,%3
         mov     b,%4
-}
+} if notVolatile %1
 
 replace {
         clr     a
@@ -1969,7 +1971,7 @@ replace {
         mov     a,#%2
         movx    @dptr,a
 } by {
-        ;       Peephole 230    replaced inefficient 16 constant
+        ;       Peephole 230    replaced inefficient 16 bit constant
         mov     dptr,#%1
         mov     a,#%2
         movx    @dptr,a
@@ -2568,7 +2570,7 @@ replace {
         movx    a,@dptr
         anl     a,#%2&%3
         movx    @dptr,a
-}
+} if notVolatile %1
 
 replace {
         mov     dptr,#%1
@@ -2585,7 +2587,7 @@ replace {
         movx    a,@dptr
         orl     a,#%2|%3
         movx    @dptr,a
-}
+} if notVolatile %1
 
 replace {
         mov     dptr,#%1
@@ -2603,7 +2605,7 @@ replace {
         orl     a,#%2
         anl     a,#%3
         movx    @dptr,a
-}
+} if notVolatile %1
 
 replace {
         mov     dptr,#%1
@@ -2621,7 +2623,7 @@ replace {
         anl     a,#%2
         orl     a,#%3
         movx    @dptr,a
-}
+} if notVolatile %1
 
 replace {
         mov     dptr,#%1
@@ -2640,7 +2642,7 @@ replace {
         orl     a,#%2
         anl     a,#%3&%4
         movx    @dptr,a
-}
+} if notVolatile %1
 
 replace {
         mov     dptr,#%1
@@ -2660,7 +2662,7 @@ replace {
         anl     a,#%3
         orl     a,#%4
         movx    @dptr,a
-}
+} if notVolatile %1
 
 replace {
         mov     dptr,#%1
@@ -2680,7 +2682,7 @@ replace {
         orl     a,#%3
         anl     a,#%4
         movx    @dptr,a
-}
+} if notVolatile %1
 
 replace {
         mov     dptr,#%1
@@ -2699,7 +2701,7 @@ replace {
         anl     a,#%2
         orl     a,#%3|%4
         movx    @dptr,a
-}
+} if notVolatile %1
 
 
 
@@ -2720,7 +2722,7 @@ replace {
         mov     a,@r%5
         anl     a,#%2&%3
         mov     @r%5,a
-}
+} if notVolatile %1
 
 replace {
         mov     r%5,#%1
@@ -2737,7 +2739,7 @@ replace {
         mov     a,@r%5
         orl     a,#%2|%3
         mov     @r%5,a
-}
+} if notVolatile %1
 
 replace {
         mov     r%5,#%1
@@ -2755,7 +2757,7 @@ replace {
         orl     a,#%2
         anl     a,#%3
         mov     @r%5,a
-}
+} if notVolatile %1
 
 replace {
         mov     r%5,#%1
@@ -2773,7 +2775,7 @@ replace {
         anl     a,#%2
         orl     a,#%3
         mov     @r%5,a
-}
+} if notVolatile %1
 
 replace {
         mov     r%5,#%1
@@ -2792,7 +2794,7 @@ replace {
         orl     a,#%2
         anl     a,#%3&%4
         mov     @r%5,a
-}
+} if notVolatile %1
 
 replace {
         mov     r%5,#%1
@@ -2812,7 +2814,7 @@ replace {
         anl     a,#%3
         orl     a,#%4
         mov     @r%5,a
-}
+} if notVolatile %1
 
 replace {
         mov     r%5,#%1
@@ -2832,7 +2834,7 @@ replace {
         orl     a,#%3
         anl     a,#%4
         mov     @r%5,a
-}
+} if notVolatile %1
 
 replace {
         mov     r%5,#%1
@@ -2851,7 +2853,7 @@ replace {
         anl     a,#%2
         orl     a,#%3|%4
         mov     @r%5,a
-}
+} if notVolatile %1
 
 
 // Peepholes 248.x have to be compatible with the keyword volatile.
@@ -3052,3 +3054,4 @@ replace {
         xrl     a,%4
         movx    @dptr,a
 }
+