1 // peeph-z80.def - Z80 peephole rules
4 // (c) Philipp Klaus Krause (pkk@spth.de, philipp@colecovision.eu) 2006 - 2007
6 // This program is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option) any
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ; peephole z1 used #%2 directly instead of going through %1 using indirect addressing.
39 ; peephole z2 directly used #%2 instead of going through %1 using indirect addressing.
52 ; peephole z3 used #%2 directly instead of going through %1 using indirect addressing.
55 } if operandsNotRelated(%3 'a')
65 ; peephole z4 directly used address #%1 + %2 instead of placing it in bc first.
77 ; peephole z5 directly used address #%1 + %2 + %6 instead of placing it in bc first.
90 ; peephole z6 directly used address #%1 + %2 instead of placing it in bc first.
104 ; peephole z7 directly used address #%1 + %2 + %6 instead of placing it in bc first.
115 ; peephole z8 moved %1 directly into l instead of going through c.
127 ; peephole z9 moved hl directly to the stack instead of going through bc.
139 ; peephole z10 moved hl directly to the stack instead of going through de.
147 ; peephole z11 replaced jump by return.
148 } if labelIsReturnOnly(), labelRefCountChange(%5 -1)
154 ; peephole z12 replaced jump by return.
155 } if labelIsReturnOnly(), labelRefCountChange(%5 -1)
157 // Should be one of the last ones. Opens the code to further peephole optimization.
161 ; peephole z13 removed unused label %1.
162 } if labelRefCount(%1 0)
164 // These should be the last rules, so that the peepholes above need to look at jp only.
169 ; peephole z14 changed absolute to relative conditional jump.
176 ; peephole z15 changed absolute to relative conditional jump.
183 ; peephole z16 changed absolute to relative conditional jump.
190 ; peephole z17 changed absolute to relative conditional jump.
197 ; peephole z18 changed absolute to relative conditional jump.