Skip to content

Commit 6d3f89e

Browse files
committed
Add 2 new optimizers
Also refactorize some of them for faster evalulation
1 parent 4249bd6 commit 6d3f89e

File tree

6 files changed

+81
-2
lines changed

6 files changed

+81
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
;; Replaces sequence:
2+
;; or|xor|and a
3+
;; sbc a, a
4+
;; with
5+
;; xor a
6+
7+
OLEVEL: 1
8+
OFLAG: 14
9+
10+
REPLACE {{
11+
$1 a
12+
sbc a, a
13+
}}
14+
15+
IF {{
16+
($1 IN (or, and, xor))
17+
}}
18+
19+
WITH {{
20+
xor a
21+
}}
22+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
;; Removes sequence
2+
;; ld a, XXXX
3+
;; if a is not used later
4+
5+
OLEVEL: 3
6+
OFLAG: 15
7+
8+
REPLACE {{
9+
ld a, $1
10+
}}
11+
12+
IF {{
13+
!IS_REQUIRED(a)
14+
}}
15+
16+
WITH {{
17+
}}
18+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
;; Replaces sequence:
2+
;; or|xor|and a
3+
;; sbc a, a
4+
;; with
5+
;; xor a
6+
7+
OLEVEL: 1
8+
OFLAG: 17
9+
10+
REPLACE {{
11+
xor a
12+
$1 z, $2
13+
}}
14+
15+
IF {{
16+
($1 IN (jp, jr))
17+
}}
18+
19+
WITH {{
20+
$1 $2
21+
}}
22+

arch/zx48k/peephole/opts/027_ld_h_a_oper_A.opt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ REPLACE {{
1414
}}
1515

1616
IF {{
17-
(($2 == or) || ($2 == xor) || ($2 == and) || ($2 == cp) || ($2 == sub) || ($2 == "add a,") || ($2 == "sbc a,"))
17+
($2 IN (or, xor, and, cp, sub, "add a,", "sbc a,"))
1818
}}
1919

2020
WITH {{

arch/zx48k/peephole/opts/030_ora_jp_nc_jp.opt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ REPLACE {{
1414
}}
1515

1616
IF {{
17-
(($1 == or) || ($1 == and)) && (($2 == jp) || ($2 == jr))
17+
($1 IN (or, xor, and, cp, sub)) && (($2 == jp) || ($2 == jr))
1818
}}
1919

2020
WITH {{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
;; Removes useless XOR a
2+
3+
OLEVEL: 3
4+
OFLAG: 103
5+
6+
REPLACE {{
7+
$1 $2
8+
}}
9+
10+
IF {{
11+
($1 IN (and, or)) &&
12+
(($2 == a) || (!IS_REQUIRED(a))) &&
13+
!IS_REQUIRED(f)
14+
}}
15+
16+
WITH {{
17+
}}

0 commit comments

Comments
 (0)