Parse peephole snippets to generate pCode
[fw/sdcc] / src / pic / peeph.def
1 //bogus test for pcode
2 replace restart {
3         movf    %1,w    ;comment at end
4 %4:     movf    %1,w
5         %2      %3,w
6 } by {
7         ; peep test remove redundant move
8 %4:     movf    %1,w    ;another comment
9         %2      %3,w
10 } if AYBABTU %3
11
12
13 // peep 1
14 replace restart {
15         movf    %1,w
16         movwf   %2
17         movf    %2,w
18 } by {
19         ; peep 1 - Removed redundant move
20         movf    %1,w
21         movwf   %2
22 }
23
24 // peep 2
25 replace restart {
26         decf    %1,f
27         movf    %1,w
28         btfss   status,z
29         goto    %2
30 } by {
31         ; peep 2 - decf/mov/skpz to decfsz
32         decfsz  %1,f
33          goto   %2
34 }
35
36 // peep 3
37 replace restart {
38         movwf   %1
39         movf    %1,w
40         xorlw   %2
41 } by {
42         ; peep 3 - redundant move
43         movwf   %1
44         xorlw   %2
45 }
46
47 // peep 4
48 replace restart {
49         btfsc   %1,%2
50         goto    %3
51         incf    %4,f
52 %3:
53 } by {
54         ;peep 4 - test/jump to test/skip
55         btfss   %1,%2
56         incf   %4,f
57 %3:
58 }
59
60
61 // peep 5
62 replace restart {
63         btfss   %1,%2
64         goto    %3
65         incf    %4,f
66 %3:
67 } by {
68         ;peep 5 - test/jump to test/skip
69         btfsc   %1,%2
70         incf   %4,f
71 %3:
72 }
73
74 // peep 6
75 replace restart {
76         btfss   %1,%2
77         goto    %3
78 %4:
79         incf    %5,f
80 %3:
81 } by {
82         ;peep 6 - test/jump to test/skip
83         btfsc   %1,%2
84 %4:
85         incf   %5,f
86 %3:
87 }
88
89 // peep 7
90 replace restart {
91         btfsc   %1,%2
92         goto    %3
93 %4:
94         incf    %5,f
95 %3:
96 } by {
97         ;peep 6 - test/jump to test/skip
98         btfss   %1,%2
99 %4:
100         incf   %5,f
101 %3:
102 }
103
104 replace restart {
105         movf    %1,w
106         movf    %1,w
107 } by {
108         ; peep 8 - Removed redundant move
109         movf    %1,w
110 }
111
112 replace restart {
113         movwf   %1
114         movf    %1,w
115 } by {
116         ; peep 9 - Removed redundant move
117         movwf   %1
118 }
119
120 replace restart {
121         movlw   %1
122         movwf   %2
123         movlw   %1
124 } by {
125         ; peep 10 - Removed redundant move
126         movlw   %1
127         movwf   %2
128 }
129
130 replace restart {
131         movwf   %1
132         movwf   %1
133 } by {
134         ; peep 11 - Removed redundant move
135         movwf   %1
136 }
137