Many, many improvements made, ususually small ones.

For example: many em-patterns have got alternative code-rules.
This commit is contained in:
garde 1985-02-01 12:51:56 +00:00
parent ca219d89e9
commit 8e154eb826

View file

@ -54,8 +54,8 @@ SETS
reg1 = reg + lbreg + mem .
bdhsp = regpair + stackpointer .
bdhpsw = regpair + psword .
immediate2 = const2 + label .
src1 = reg + const1 .
immediate = const2 + label .
src1 = reg .
src2 = hlorde + const2 + label .
src1or2 = src1 + src2 .
@ -103,7 +103,7 @@ INSTRUCTIONS
lda label:ro kills a cost(3,13) .
ldax regind:ro kills a cost(1,7) .
lhld label:ro kills hl cost(3,16) .
lxi bdhsp:wo,immediate2:ro cost(3,10) .
lxi bdhsp:wo,immediate:ro cost(3,10) .
mov reg1:wo,reg1:ro cost(1,5) .
mvi reg1:wo,const1:ro cost(2,7) .
/* nop cost(1,0) . */
@ -128,14 +128,14 @@ INSTRUCTIONS
/* rst const1:ro cost(1,11) . */
/* rz cost(1,8) . */
sbb reg1:ro kills a:cc cost(1,4) .
sbi const1:ro kills a:cc cost(2,7) .
/* sbi const1:ro kills a:cc cost(2,7) . */
shld label:ro cost(3,16) .
sphl cost(1,5) .
sta label:ro cost(3,13) .
stax regind:ro cost(1,7) .
/* stc kills:cc cost(1,4) . */
sub reg1:ro kills a:cc cost(1,4) .
/* sui const1:ro kills a:cc cost(2,7) . */
sui const1:ro kills a:cc cost(2,7) .
xchg kills de hl cost(1,4) .
xra reg1:ro kills a:cc cost(1,4) .
/* xri const1:ro kills a:cc cost(2,7) . */
@ -147,16 +147,16 @@ MOVES
from reg to reg
gen mov %2,%1
from const1 to reg
gen mvi %2,%1
from immediate to bdhsp
gen lxi %2,%1
from reg to regpair
gen mov %2.2,%1
mvi %2.1,{const1,0}
from immediate2 to bdhsp
gen lxi %2,%1
from const1 to reg
gen mvi %2,%1
from regpair to regpair
gen mov %2.1,%1.1
mov %2.2,%1.2
@ -164,7 +164,7 @@ gen mov %2.1,%1.1
TESTS
to test areg /* just a dummy test, never used */
gen cmp %1
gen ora a
STACKINGRULES
@ -181,12 +181,12 @@ gen push hl
move %1,hl
xthl.
from immediate2 to STACK
from immediate to STACK
uses hlorde
gen lxi %a,%1
push %a
from immediate2 to STACK
from immediate to STACK
gen push hl
move %1,hl
xthl.
@ -207,7 +207,7 @@ gen dcx sp
pop psw
inx sp yields a
from immediate2
from immediate
uses regpair
gen move %1,%a yields %a
@ -222,6 +222,10 @@ gen mov %a.2,%1
from hlorde yields %1.2
from hlorde
uses areg
gen mov a,%1.2 yields a
PATTERNS
/*********************************************/
@ -266,6 +270,7 @@ gen dad lb
pat lof
with hlorde
kills hlorde
uses hlorde={const2,$1}
gen dad de
mov e,m
@ -330,13 +335,15 @@ gen move lb,de
dad de yields hl
pat loi $1==1
with exact label
uses areg
gen lda %1 yields a
with dereg
uses areg
gen ldax de yields a
with hlreg
uses reg
gen mov %a,m yields %a
with dereg
gen ldax de yields a
with exact label
gen lda %1 yields a
pat loi $1==2
with exact label
@ -352,16 +359,20 @@ with exact label
gen lhld %1
xchg.
lhld {label,%1.off+2} yields hl de
with exact label
gen lhld {label,%1.off+2}
xchg.
lhld %1 yields de hl
with hlreg
uses dereg, areg
gen mov e,m
inx %1
mov d,m
inx %1
inx hl
mov a,m
inx %1
mov %1.1,m
mov %1.2,a yields hl de
inx hl
mov h,m
mov l,a yields hl de
pat loi $1<=510
with hlorde STACK
@ -404,6 +415,16 @@ with STACK
gen lhld {label,$1+2}
push hl
lhld {label,$1} yields hl
with
uses dereg, hlreg
gen lhld {label,$1}
xchg.
lhld {label,$1+2} yields hl de
with
uses dereg, hlreg
gen lhld {label,$1+2}
xchg.
lhld {label,$1} yields de hl
pat ldf
with hlorde STACK
@ -488,12 +509,12 @@ gen dad lb
mov m,e
pat lil inc sil $1==$3
uses hlreg={const2,$1}
uses hlreg={const2,$1}, areg
gen dad lb
mov e,m
mov a,m
inx hl
mov h,m
mov l,e
mov l,a
inr m
jnz {label,"1f"}
inx hl
@ -501,7 +522,7 @@ gen dad lb
1:
pat lil dec sil $1==$3
uses hlreg={const2,$1}
uses hlreg={const2,$1}, dereg
gen dad lb
mov e,m
inx hl
@ -527,14 +548,15 @@ gen dad de
pat sti $1==1
with exact label areg
gen sta %1
with hlreg reg
gen mov m,%2
with exact dereg areg
gen stax de
with hlreg reg
gen mov m,%2
pat sti $1==2
with exact label hlreg
uses hlreg
gen shld %1
with hlreg dereg
gen mov m,e
@ -552,23 +574,23 @@ with exact label dereg hlreg
shld %1
with hlreg dereg STACK
gen mov m,e
inx %1
inx hl
mov m,d
inx hl
pop de
mov m,e
inx hl
mov m,d
inx %1
pop %2
mov m,%2.2
inx %1
mov m,%2.1
pat sti $1<511
with hlreg STACK
uses areg ={const1,$1/2}, dereg
uses areg={const1,$1/2}, dereg
gen 1:
pop de
mov m,e
inx %1
inx hl
mov m,d
inx %1
inx hl
dcr a
jnz {label,"1b"}
@ -599,6 +621,14 @@ with hlreg STACK
gen shld {label,$1}
pop hl
shld {label,$1+2}
with hlreg dereg STACK
gen shld {label,$1}
xchg.
shld {label,$1+2}
with dereg hlreg STACK
gen shld {label,$1+2}
xchg.
shld {label,$1}
pat sdf
with hlorde STACK
@ -620,7 +650,7 @@ gen dad de
pat adi $1==2
with hlreg dereg
gen dad de yields hl
gen dad de yields hl
with dereg hlreg
gen dad de yields hl
with hlreg hlreg
@ -639,6 +669,14 @@ gen mov a,%2.2
mov a,%2.1
sbb %1.1
mov %2.1,a yields %2
with hlorde hlorde
uses areg
gen mov a,%2.2
sub %1.2
mov %1.2,a
mov a,%2.1
sbb %1.1
mov %1.1,a yields %1
pat sbi $1==4
with STACK
@ -712,7 +750,13 @@ pat adu leaving adi $1
pat sbu leaving sbi $1
pat mlu leaving mli $1
pat mlu $1==2
with STACK
gen Call {label,".mlu2"} yields de
pat mlu $1==4
with STACK
gen Call {label,".mli4"}
pat dvu $1==2
with STACK
@ -788,7 +832,7 @@ with hlorde
gen inx %1 yields %1
pat inl
uses hlreg={const2,$1}, dereg
uses hlreg={const2,$1}
gen dad lb
inr m
jnz {label,"1f"}
@ -868,34 +912,31 @@ gen xra a
pat loc loc cii $1==$2
pat loc loc cii $1==2 && $2==4
with dereg
uses hlreg
gen move {const2,0},hl
mov a,d
ral.
jnc {label,"1f"}
lxi hl,{const2,0-1}
1: yields hl de
with hlorde
uses hlorde={const2,0}, areg
gen mov a,%1.1
ora a
jp {label,"1f"}
lxi %a,{const2,0-1}
1: yields %a %1
pat loc loc cii $1==4 && $2==2
with hlreg dereg yields hl
with dereg hlreg yields de
with hlorde hlorde yields %1
pat loc loc cii $1==1 && $2==2
with reg
uses areg, hlorde
gen move %1,a
move {const1,0},%b.1
uses areg=%1, hlorde
gen move {const1,0},%b.1
move a,%b.2
ral.
jnc {label,"1f"}
ora a
jp {label,"1f"}
mvi %b.1,{const1,255}
1: yields %b
with hlorde
uses areg=%1.2
gen move {const1,0},%1.1
move %1.2,a
ral.
jnc {label,"1f"}
ora a
jp {label,"1f"}
mvi %1.1,{const1,255}
1: yields %1
@ -905,11 +946,11 @@ with reg
gen move %1,l yields hl
leaving loc $1 loc $2 cii
with hlreg
uses dereg
gen move {const1,0},h
uses dereg, areg
gen move {const1,0},%1.1
move l,a
ral.
jnc {label,"1f"}
ora a
jp {label,"1f"}
mvi h,{const1,255}
1:
mov e,h
@ -930,22 +971,21 @@ pat ciu leaving cuu $1
pat loc loc cuu $1==$2
pat loc loc cuu $1==2 && $2==4
with dereg yields {const2,0} de
with src1or2 yields {const2,0} %1
pat loc loc cuu $1==4 && $1==2
with hlreg dereg yields hl
with dereg hlreg yields de
with src1or2 src1or2 yields %1
pat loc loc cuu $1==1 && $2==2
with reg
uses hlorde
uses reusing %1, hlorde
gen move %1,%a yields %a
with hlorde
gen move {const1,0},%1.1 yields %1
pat loc loc cuu $1==1 && $2==4
with reg
uses hlorde
uses reusing %1, hlorde
gen move %1,%a yields {const2,0} %a
with hlorde
gen move {const1,0},%1.1 yields {const2,0} %1
@ -968,6 +1008,14 @@ gen mov a,%1.2
mov a,%1.1
ana %2.1
mov %2.1,a yields %2
with hlorde hlorde
uses areg
gen mov a,%1.2
ana %2.2
mov %1.2,a
mov a,%1.1
ana %2.1
mov %1.1,a yields %1
pat and defined($1)
with STACK
@ -987,6 +1035,14 @@ gen mov a,%1.2
mov a,%1.1
ora %2.1
mov %2.1,a yields %2
with hlorde hlorde
uses areg
gen mov a,%1.2
ora %2.2
mov %1.2,a
mov a,%1.1
ora %2.1
mov %1.1,a yields %1
pat ior defined($1)
with STACK
@ -1006,6 +1062,14 @@ gen mov a,%1.2
mov a,%1.1
xra %2.1
mov %2.1,a yields %2
with hlorde hlorde
uses areg
gen mov a,%1.2
xra %2.2
mov %1.2,a
mov a,%1.1
xra %2.1
mov %1.1,a yields %1
pat xor defined($1)
with STACK
@ -1026,11 +1090,15 @@ gen mov a,%1.2
cma.
mov %1.1,a yields %1
pat com
pat com defined($1)
with STACK
uses dereg={const2,$1}
gen Call {label,".com"}
pat com !defined($1)
with dereg STACK
gen Call {label,".com"}
pat rol $1==2
with dereg hlreg STACK
uses areg
@ -1047,33 +1115,8 @@ gen mov a,e
3: yields hl
pat rol $1==4
with hlorde hlorde STACK
uses areg
gen mov a,%1.2
pop %1
push lb
ani {const1,31}
jz {label,"2f"}
mov c,a
mov a,%1.1
ral. /* set carry bit iff bit 31 is set */
1:
mov a,%2.2
ral.
mov %2.2,a
mov a,%2.1
ral.
mov %2.1,a
mov a,%1.2
ral.
mov %1.2,a
mov a,%1.1
ral.
mov %1.1,a
dcr c
jnz {label,"1b"}
2:
pop lb yields %1 %2
with dereg STACK
gen Call {label,".rol4"}
pat ror $1==2
with dereg hlreg STACK
@ -1096,33 +1139,8 @@ gen mov a,e
2: yields hl
pat ror $1==4
with hlorde hlorde STACK
uses areg
gen mov a,%1.2
pop %1
push lb
ani {const1,31}
jz {label,"2f"}
mov c,a
mov a,%2.2
rar.
1:
mov a,%1.1
rar.
mov %1.1,a
mov a,%1.2
rar.
mov %1.2,a
mov a,%2.1
rar.
mov %2.1,a
mov a,%2.2
rar.
mov %2.2,a
dcr c
jnz {label,"1b"}
2:
pop lb yields %1 %2
with dereg STACK
gen Call {label,".ror4"}
/***********************************************/
/* Group 10: Set instructions */
@ -1130,15 +1148,20 @@ gen mov a,%1.2
pat inn $1==2
with STACK
gen Call {label,".inn2"} yields de
gen Call {label,".inn2"} yields de
pat inn
pat inn defined($1)
with STACK
gen Call {label,".inn"} yields de
uses dereg={const2,$1}
gen Call {label,".inn"} yields de
pat inn !defined($1)
with dereg STACK
gen Call {label,".inn"} yields de
pat set $1==2
with dereg STACK
gen Call {label,".set2"} yields de
gen Call {label,".set2"} yields de
pat set defined($1)
with STACK
@ -1201,6 +1224,7 @@ gen Call {label,"eunimpl"}
pat lar !defined($1)
with hlorde STACK
uses areg
gen mov a,%1.2
cpi {const1,2}
cnz {label,"eunimpl"}
@ -1218,6 +1242,7 @@ gen Call {label,"eunimpl"}
pat sar !defined($1)
with hlorde STACK
uses areg
gen mov a,%1.2
cpi {const1,2}
cnz {label,"eunimpl"}
@ -1235,6 +1260,7 @@ gen Call {label,"eunimpl"}
pat aar !defined($1)
with hlorde STACK
uses areg
gen mov a,%1.2
cpi {const1,2}
cnz {label,"eunimpl"}
@ -1295,6 +1321,7 @@ pat cmp leaving cmu 2
pat tlt
with hlorde
uses areg
gen mov a,%1.1
ral.
mvi a,{const1,0}
@ -1318,6 +1345,7 @@ gen xra a
pat teq
with hlorde
uses areg
gen mov a,%1.1
ora %1.2
move {const2,0},%1
@ -1327,6 +1355,7 @@ gen mov a,%1.1
pat tne
with hlorde
uses areg
gen mov a,%1.1
ora %1.2
move {const2,0},%1
@ -1336,6 +1365,7 @@ gen mov a,%1.1
pat tge
with hlorde
uses areg
gen mov a,%1.1
ral.
cmc.
@ -1364,8 +1394,17 @@ gen cpi {const1,$1}
jz {label,"1f"}
move {const2,0},%2
1: yields %2
with yields {const2,$1}
leaving cmi 2 teq and 2
with hlorde hlorde
uses areg
gen mov a,%1.2
cpi {const1,$1}
jnz {label,"1f"}
mov a,%1.1
ora a
jz {label,"2f"}
1:
move {const2,0},%2
2: yields %2
pat loc cmi tne and $1>=0 && $1<=255 && $2==2 && $4==2
with exact areg hlorde
@ -1373,26 +1412,51 @@ gen cpi {const1,$1}
jnz {label,"1f"}
move {const2,0},%2
1: yields %2
with yields {const2,$1}
leaving cmi 2 tne and 2
with hlorde hlorde
uses areg
gen mov a,%1.2
cpi {const1,$1}
jnz {label,"1f"}
mov a,%1.1
ora a
jnz {label,"1f"}
move {const2,0},%2
1: yields %2
pat loc cmi teq ior $1>=0 && $1<=255 && $2==2 && $4==2
with exact areg hlorde
gen cpi {const1,$1}
jnz {label,"1f"}
move {const1,1},%2.2
move {const2,1},%2
1: yields %2
with hlorde hlorde
uses areg
gen mov a,%1.2
cpi {const1,$1}
jnz {label,"1f"}
mov a,%1.1
ora a
jnz {label,"1f"}
move {const2,1},%2
1: yields %2
with yields {const2,$1}
leaving cmi 2 teq ior 2
pat loc cmi tne ior $1>=0 && $1<=255 && $2==2 && $4==2
with exact areg hlorde
gen cpi {const1,$1}
jz {label,"1f"}
move {const1,1},%2.2
move {const2,1},%2
1: yields %2
with yields {const2,$1}
leaving cmi 2 tne ior 2
with hlorde hlorde
uses areg
gen mov a,%1.2
cpi {const1,$1}
jnz {label,"1f"}
mov a,%1.1
ora a
jz {label,"2f"}
1:
move {const2,1},%2
2: yields %2
pat loc cmi teq $1>=0 && $1<=255 && $2==2
with exact areg
@ -1401,8 +1465,16 @@ gen cpi {const1,$1}
jnz {label,"1f"}
inx %a
1: yields %a
with yields {const2,$1}
leaving cmi 2 teq
with hlorde
uses hlorde={const2,0}, areg
gen mov a,%1.2
cpi {const1,$1}
jnz {label,"1f"}
mov a,%1.1
ora a
jnz {label,"1f"}
inx %a
1: yields %a
pat loc cmi tne $1>=0 && $1<=255 && $2==2
@ -1412,13 +1484,21 @@ gen cpi {const1,$1}
jz {label,"1f"}
inx %a
1: yields %a
with yields {const2,$1}
leaving cmi 2 tne
with hlorde
uses hlorde={const2,1}, areg
gen mov a,%1.2
cpi {const1,$1}
jnz {label,"1f"}
mov a,%1.1
ora a
jnz {label,"1f"}
dcx %a
1: yields %a
pat loc cmi $1>=0 && $1<=255 && $2==2
with exact areg
uses hlorde
gen sbi {const1,$1}
gen sui {const1,$1}
mov %a.2,a
rar.
mov %a.1,a yields %a
@ -1500,10 +1580,10 @@ with STACK
gen pop psw
ral.
jc {label,$1}
with hlorde
with hlorde STACK
gen mov a,%1.1
ral.
jc {label,$1}
ora a
jm {label,$1}
pat zle
with hlorde STACK
@ -1536,10 +1616,10 @@ with STACK
gen pop psw
ral.
jnc {label,$1}
with hlorde
with hlorde STACK
gen mov a,%1.1
ral.
jnc {label,$1}
ora a
jp {label,$1}
pat zgt
with hlorde STACK
@ -1554,7 +1634,8 @@ gen xra a
1:
pat lol zeq
uses hlreg={const2,$1}
with STACK
uses hlreg={const2,$1}, areg
gen dad lb
mov a,m
inx hl
@ -1562,7 +1643,8 @@ gen dad lb
jz {label,$2}
pat lol zne
uses hlreg={const2,$1}
with STACK
uses hlreg={const2,$1}, areg
gen dad lb
mov a,m
inx hl
@ -1570,7 +1652,8 @@ gen dad lb
jnz {label,$2}
pat ior zeq $1==2
with hlorde hlorde
with hlorde hlorde STACK
uses areg
gen mov a,%1.1
ora %1.2
ora %2.1
@ -1578,7 +1661,8 @@ gen mov a,%1.1
jz {label,$2}
pat ior zne $1==2
with hlorde hlorde
with hlorde hlorde STACK
uses areg
gen mov a,%1.1
ora %1.2
ora %2.1
@ -1605,7 +1689,7 @@ pat lfr $1==2 yields de
pat lfr $1<=8
with STACK
uses areg={const1,$1/2}, hlreg={label,".fra"+$1}
uses areg={const1,$1/2}, hlreg={label,".fra"+$1}, dereg
gen 1:
dcx hl
mov d,m
@ -1635,7 +1719,7 @@ gen move lb,hl
pat ret $1<=8
with STACK
uses areg={const1,$1/2}, hlreg={label,".fra"}
uses areg={const1,$1/2}, hlreg={label,".fra"}, dereg
gen 1:
pop de
mov m,e
@ -1719,10 +1803,10 @@ gen jmp {label,".csb"}
pat dch leaving loi 2
pat dup $1==2
with hlorde yields %1 %1
with src1or2 yields %1 %1
pat dup $1==4
with hlorde hlorde yields %2 %1 %2 %1
with src1or2 src1or2 yields %2 %1 %2 %1
pat dup
with STACK
@ -1734,7 +1818,7 @@ with dereg STACK
gen Call {label,".dup"}
pat exg $1==2
with src2 src2 yields %1 %2
with src1or2 src1or2 yields %1 %2
pat exg defined($1)
with STACK
@ -1742,6 +1826,7 @@ uses dereg={const2,1}
gen Call {label,".exg"}
pat fil
uses hlreg
gen lxi hl,{label,$1}
shld {label,"hol0"+4}
@ -1755,6 +1840,7 @@ gen lhld {label,$1+2}
pchl.
pat lim
uses hlreg
gen lhld {label,".ignmask"} yields hl
pat lin
@ -1762,6 +1848,7 @@ uses hlreg={const2,$1}
gen shld {label,"hol0"}
pat lni
uses hlreg
gen lhld {label,"hol0"}
inx hl
shld {label,"hol0"}
@ -1774,6 +1861,7 @@ uses hlreg={const2,0}
gen dad sp yields hl
pat lor $1==2
uses hlreg
gen lhld {label,".reghp"} yields hl
pat lpb leaving adp SL
@ -1793,10 +1881,12 @@ pat rtt leaving ret 0
pat sig
with dereg
uses hlreg
gen lhld {label,".trapproc"}
xchg.
shld {label,".trapproc"} yields de
with STACK
uses hlreg
gen lhld {label,".trapproc"}
xthl.
shld {label,".trapproc"}
@ -1809,8 +1899,8 @@ pat str $1==0
with localbase
pat str $1==1
with STACK
gen pop psw
with hlreg
gen sphl.
pat str $1==2
with hlreg