What is the best way of creating peep hole rules that recurse from the bottom to the top? I mark them with comments, but that results in other rules not being able to detect them.
Is there a better way of doing this?
Is this a sign such things should be rather done in the code generator?

Currently I'm doing it like this:

```
// especially needed by HIDE_BKG etc
replace {
 ldh    a, (%1)
 and    a, #%2
 ldh    (%1), a
 ldh    a, (%1)
 and    a, #%3
 ldh    (%1), a
} by {
 ; switched to ldh (c)
 ld     c, #<(%1)
 ldh    a, (c)
 and    a, #%2
 ldh    (c), a
 ldh    a, (c)
 and    a, #%3
 ldh    (c), a ; c is #<(%1)
} if notUsed('c'), notSame(%1 'c')

replace {
 ldh    (c), a ; c is #<(%1)
 ldh    a, (%1)
 and    a, #%2
 ldh    (%1), a
} by {
 ; switched to ldh (c)
 ldh    (c), a
 ldh    a, (c)
 and    a, #%2
 ldh    (c), a ; c is #<(%1)
} if notSame(%1 'c')
```
Background: `ldh (c), a` is one, `ldh (#0xffXX), a` is 2 bytes and `ld (#0xffXX), a` is 3 bytes.
`ldh (c), a` is ultimately a faster version of `ldh (hl), a`.
--
Freundliche Grüße / Yours sincerely
Sebastian Riedel


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to