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

@ -157,94 +157,149 @@ INSTRUCTIONS
MOVES MOVES
from reg to reg from reg to reg
gen mov %2,%1 gen
mov %2,%1
from const1 %num==0 to areg from const1 %num==0 to areg
gen xra a gen
xra a
from const1 to reg from const1 to reg
gen mvi %2,%1 gen
mvi %2,%1
from immediate to b_d_h_sp from immediate to b_d_h_sp
gen lxi %2,%1 gen
lxi %2,%1
from reg to regpair #if 0
gen mov %2.2,%1 from const1 to reg
mvi %2.1,{const1,0} gen
mvi %2, %1
from const1 to regpair
gen
mvi %2.2, %1
mvi %2.1, {const1, 0}
#endif
from regpair to regpair from reg to regpair
gen mov %2.1,%1.1 gen
mov %2.2,%1.2 mov %2.2, %1
mvi %2.1, {const1,0}
from regpair to regpair
gen
mov %2.1, %1.1
mov %2.2, %1.2
TESTS TESTS
to test areg /* dummy test, never used */ to test areg /* dummy test, never used */
gen ora a gen
ora a
STACKINGRULES STACKINGRULES
from regpair to STACK from regpair to STACK
gen push %1 gen
push %1
from immediate + reg to STACK from immediate + reg to STACK
uses hl_or_de uses hl_or_de
gen move %1,%a gen
push %a move %1, %a
push %a
from immediate + reg to STACK from immediate + reg to STACK
gen push hl gen
move %1,hl push hl
xthl. move %1, hl
xthl.
COERCIONS COERCIONS
from STACK from STACK
uses regpair uses regpair
gen pop %a yields %a gen
pop %a
yields %a
from STACK from STACK
uses hl_or_de uses hl_or_de
gen pop %a yields %a.2 gen
pop %a
yields %a.2
from STACK from STACK
uses areg uses areg
gen dcx sp gen
pop psw dcx sp
inx sp yields a pop psw
inx sp
yields %a
from immediate from immediate
uses regpair uses regpair=%1
gen move %1,%a yields %a yields %a
from hl_or_de from hl_or_de
uses hl_or_de uses hl_or_de
gen xchg. yields %a gen
xchg.
yields %a
from regpair from regpair
uses regpair uses regpair=%1
gen move %1,%a yields %a yields %a
from reg from reg
uses reusing %1, hl_or_de uses reusing %1, hl_or_de
gen move %1,%a.2 gen
move {const1,0},%a.1 yields %a move %1,%a.2
move {const1,0},%a.1
yields %a
from hl_or_de yields %1.2 from hl_or_de yields %1.2
from smallpconst2 from smallpconst2
yields {const2, %1.num} yields {const2, %1.num}
from smallnconst2 from smallnconst2
yields {const2, %1.num} yields {const2, %1.num}
from const2 from const2
uses hl_or_de uses hl_or_de=%1
gen move %1,%a yields %a.2 yields %a
from hl_or_de from smallpconst2
uses areg uses reg={const1, %1.num & 0xff}
gen move %1.2,a yields a 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 reg=%1.2
yields %a
PATTERNS PATTERNS
@ -569,13 +624,15 @@ pat stf
mov {m},d mov {m},d
pat sti $1==1 pat sti $1==1
with label areg with label areg
gen sta %1 gen
with dereg areg sta %1
gen stax de with dereg areg
with hlreg reg gen
gen mov {m},%2 stax %1
with hlreg reg
gen
mov {m}, %2
pat sti $1==2 pat sti $1==2
with label hlreg with label hlreg