struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / src / z80 / peeph-tlcs90.def
blob953aa80b5dc8f5c851965c7a2132ecb8501fdf01
1 // peeph-tlcs90.def - TLCS-90 peephole rules
2 //
3 // (c) Philipp Klaus Krause (pkk@spth.de, philipp@colecovision.eu) 2006 - 2015
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the
7 // Free Software Foundation; either version 2, or (at your option) any
8 // later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 replace restart {
20 ld %1, %7
21 ld %5 (%6), %4
22 ld %2 (%3), %1
23 } by {
24 ld %5 (%6), %4
25 ; tlcs90 peephole 0 loaded %7 into %2 (%3) directly instead of going through %1.
26 ld %2 (%3), %7
27 } if canAssign(%2 %3 %7), notVolatile(%1), notUsed(%1), notSame(%1 %4 %1 'hl')
29 replace restart {
30 ld iy, #%1+1
31 ld a, 1 (iy)
32 or a, 0 (iy)
33 } by {
34 ld hl, #%1
35 ld a, (hl)
36 dec hl
37 or a, (hl)
38 ; tlcs90 peephole 1 used hl instead of iy.
39 } if notUsed('iy'), notUsed('hl')
41 replace restart {
42 add hl, hl
43 ld e, l
44 ld d, h
45 inc de
46 inc de
47 } by {
48 inc hl
49 ; tlcs90 peephole 2 incremented once in hl instead of incrementing in de twice.
50 add hl, hl
51 ld e, l
52 ld d, h
53 } if notUsed('hl')
55 replace restart {
56 add hl, hl
57 inc hl
58 inc hl
59 } by {
60 inc hl
61 ; tlcs90 peephole 3 incremented once in hl instead of incrementing in hl twice.
62 add hl, hl
65 replace restart {
66 add a, a
67 add a, a
68 add a, #0x04
69 } by {
70 inc a
71 ; tlcs90 peephole 4 incremented a once instead of adding #0x04 to a.
72 add a, a
73 add a, a
76 replace restart {
77 add hl, hl
78 pop de
79 inc hl
80 inc hl
81 } by {
82 inc hl
83 ; tlcs90 peephole 5 incremented once in hl instead of incrementing in hl twice.
84 add hl, hl
85 pop de
88 replace {
89 ld e,#0x%1
90 ld d,#0x%2
91 } by {
92 ld de,#0x%2%1
93 ; tlcs90 peephole 6 combined constant loads into register pair.
96 replace {
97 ld d,#0x%1
98 ld e,#0x%2
99 } by {
100 ld de,#0x%1%2
101 ; tlcs90 peephole 7 combined constant loads into register pair.
104 replace {
105 ld l,#0x%1
106 ld h,#0x%2
107 } by {
108 ld hl,#0x%2%1
109 ; tlcs90 peephole 8 combined constant loads into register pair.
112 replace {
113 ld h,#0x%1
114 ld l,#0x%2
115 } by {
116 ld hl,#0x%1%2
117 ; tlcs90 peephole 9 combined constant loads into register pair.
120 replace {
121 ld c,#0x%1
122 ld b,#0x%2
123 } by {
124 ld bc,#0x%2%1
125 ; tlcs90 peephole 10 combined constant loads into register pair.
128 replace {
129 ld b,#0x%1
130 ld c,#0x%2
131 } by {
132 ld bc,#0x%1%2
133 ; tlcs90 peephole 11 combined constant loads into register pair.
136 replace restart {
137 ld %1, a
138 ld a, %2 (%3)
139 adc a, #%4
140 ld %5, a
141 ld %6, %1
142 } by {
143 ld %6, a
144 ld a, %2 (%3)
145 adc a, #%4
146 ld %5, a
147 ; tlcs90 peephole 12 loaded %6 from a directly instead of going through %1.
148 } if notUsed(%1), notSame(%5 %1), notSame(%5 '(hl)' '(de)' '(bc)'), notSame(%5 %6), notSame(%6 '(hl)' '(de)' '(bc)'), notSame(%5 'a'), notSame(%6 'a')