Add rules for converting smallnconst2 and smallpconst2 to registers, to stop

the conversion from happening via the stack. Star Trek goes from 39450 to 39384
bytes.
This commit is contained in:
David Given 2019-02-15 22:20:07 +01:00
parent afd45acb89
commit c9467b683a

View file

@ -158,42 +158,63 @@ INSTRUCTIONS
MOVES
from reg to reg
gen mov %2,%1
gen
mov %2,%1
from const1 %num==0 to areg
gen xra a
gen
xra a
from const1 to reg
gen mvi %2,%1
gen
mvi %2,%1
from immediate to b_d_h_sp
gen lxi %2,%1
gen
lxi %2,%1
#if 0
from const1 to reg
gen
mvi %2, %1
from const1 to regpair
gen
mvi %2.2, %1
mvi %2.1, {const1, 0}
#endif
from reg to regpair
gen mov %2.2,%1
gen
mov %2.2, %1
mvi %2.1, {const1,0}
from regpair to regpair
gen mov %2.1,%1.1
gen
mov %2.1, %1.1
mov %2.2, %1.2
TESTS
to test areg /* dummy test, never used */
gen ora a
gen
ora a
STACKINGRULES
from regpair to STACK
gen push %1
gen
push %1
from immediate + reg to STACK
uses hl_or_de
gen move %1,%a
gen
move %1, %a
push %a
from immediate + reg to STACK
gen push hl
gen
push hl
move %1, hl
xthl.
@ -201,34 +222,44 @@ COERCIONS
from STACK
uses regpair
gen pop %a yields %a
gen
pop %a
yields %a
from STACK
uses hl_or_de
gen pop %a yields %a.2
gen
pop %a
yields %a.2
from STACK
uses areg
gen dcx sp
gen
dcx sp
pop psw
inx sp yields a
inx sp
yields %a
from immediate
uses regpair
gen move %1,%a yields %a
uses regpair=%1
yields %a
from hl_or_de
uses hl_or_de
gen xchg. yields %a
gen
xchg.
yields %a
from regpair
uses regpair
gen move %1,%a yields %a
uses regpair=%1
yields %a
from reg
uses reusing %1, hl_or_de
gen move %1,%a.2
move {const1,0},%a.1 yields %a
gen
move %1,%a.2
move {const1,0},%a.1
yields %a
from hl_or_de yields %1.2
@ -239,12 +270,36 @@ from smallnconst2
yields {const2, %1.num}
from const2
uses hl_or_de
gen move %1,%a yields %a.2
uses hl_or_de=%1
yields %a
from smallpconst2
uses reg={const1, %1.num & 0xff}
yields %a
from smallnconst2
uses reg={const1, %1.num & 0xff}
yields %a
from smallpconst2 %1.num == 1
uses reg={const1, 0}
gen
inr %a
yields %a
from smallnconst2 %1.num == 0-1
uses reg={const1, 0}
gen
dcr %a
yields %a
from const2
uses reg={const1, %1.num & 0xff}
yields %a
from hl_or_de
uses areg
gen move %1.2,a yields a
uses reg=%1.2
yields %a
PATTERNS
@ -570,12 +625,14 @@ pat stf
pat sti $1==1
with label areg
gen sta %1
gen
sta %1
with dereg areg
gen stax de
gen
stax %1
with hlreg reg
gen mov {m},%2
gen
mov {m}, %2
pat sti $1==2
with label hlreg