Teach i80 ncg to use libfp. Enable ack -mcpm -fp.

Old .o files stop working if they use floating point.  One must
recompile those files.  Old files don't call libfp in the correct way,
and may use symbols that I removed from libem.  I don't keep old
symbols in libem/flp.s, because a program that pulls both libfp and
flp.s would get "multiply defined" errors in the linker.

I teach mach/i80/ncg/table to use libfp by copying or adapting the
patterns from mach/i86/ncg/table.  I did not test all the patterns,
but I did use `ack -mcpm -fp -O4` to compile examples/mandelbrot.c,
then I ran it in the emulator YAZE-AG.  It worked, but it was slow.
This commit is contained in:
George Koehler 2018-04-25 16:09:56 -04:00
parent b9b3428e01
commit 93e01eb5d1
4 changed files with 73 additions and 95 deletions

View file

@ -1,7 +1,6 @@
.define .adf4,.adf8,.sbf4,.sbf8,.mlf4,.mlf8,.dvf4,.dvf8 .define .adf4,.adf8,.sbf4,.sbf8,.mlf4,.mlf8,.dvf4,.dvf8
.define .ngf4,.ngf8,.fif4,.fif8,.fef4,.fef8 .define .ngf4,.ngf8,.fif4,.fif8,.fef4,.fef8
.define .zrf4,.zrf8 .define .cfi,.cif4,.cif8,.cuf4,.cuf8,.cff4,.cff8,.cfu
.define .cfi,.cif,.cuf,.cff,.cfu
.define .cmf4,.cmf8 .define .cmf4,.cmf8
.sect .text .sect .text
.sect .rom .sect .rom
@ -25,12 +24,13 @@
.fif8: .fif8:
.fef4: .fef4:
.fef8: .fef8:
.zrf4:
.zrf8:
.cfi: .cfi:
.cif: .cif4:
.cuf: .cif8:
.cff: .cuf4:
.cuf8:
.cff4:
.cff8:
.cfu: .cfu:
.cmf4: .cmf4:
.cmf8: .cmf8:

View file

@ -41,21 +41,12 @@ con_mult(sz) word sz; {
fprintf(codefile,".data4\t%ld\n",atol(str)); fprintf(codefile,".data4\t%ld\n",atol(str));
} }
void #define CODE_GENERATOR
con_float() { #define IEEEFLOAT
static int warning_given; #define FL_MSL_AT_LOW_ADDRESS 0
int i = argval; #define FL_MSW_AT_LOW_ADDRESS 0
#define FL_MSB_AT_LOW_ADDRESS 0
if (!warning_given) { #include <con_float>
fprintf(stderr, "warning: dummy floating point constant\n");
warning_given = 1;
}
while (i > 0) {
fputs(".data4 0 !dummy float\n", codefile);
i -= 4;
}
}
void void
prolog(nlocals) full nlocals; { prolog(nlocals) full nlocals; {

View file

@ -817,61 +817,28 @@ gen mvi a,{const1,0}
/* Group 5: Floating point arithmetic */ /* Group 5: Floating point arithmetic */
/********************************************/ /********************************************/
pat adf $1==4 pat adf $1==4 leaving cal ".adf4" asp 4
kills ALL pat adf $1==8 leaving cal ".adf8" asp 8
gen Call {label,".adf4"} pat sbf $1==4 leaving cal ".sbf4" asp 4
pat sbf $1==8 leaving cal ".sbf8" asp 8
pat adf $1==8 pat mlf $1==4 leaving cal ".mlf4" asp 4
kills ALL pat mlf $1==8 leaving cal ".mlf8" asp 8
gen Call {label,".adf8"} pat dvf $1==4 leaving cal ".dvf4" asp 4
pat dvf $1==8 leaving cal ".dvf8" asp 8
pat sbf $1==4 pat ngf $1==4 leaving cal ".ngf4"
kills ALL pat ngf $1==8 leaving cal ".ngf8"
gen Call {label,".sbf4"}
pat sbf $1==8
kills ALL
gen Call {label,".sbf8"}
pat mlf $1==4
kills ALL
gen Call {label,".mlf4"}
pat mlf $1==8
kills ALL
gen Call {label,".mlf8"}
pat dvf $1==4
kills ALL
gen Call {label,".dvf4"}
pat dvf $1==8
kills ALL
gen Call {label,".dvf8"}
pat ngf $1==4
kills ALL
gen Call {label,".ngf4"}
pat ngf $1==8
kills ALL
gen Call {label,".ngf8"}
pat fif $1==4 pat fif $1==4
kills ALL leaving lor 1 cal ".fif4" asp 2
gen Call {label,".fif4"}
pat fif $1==8 pat fif $1==8
kills ALL leaving lor 1 cal ".fif8" asp 2
gen Call {label,".fif8"}
pat fef $1==4 pat fef $1==4
kills ALL leaving lor 1 adp 0-2 cal ".fef4"
gen Call {label,".fef4"}
pat fef $1==8 pat fef $1==8
kills ALL leaving lor 1 adp 0-2 cal ".fef8"
gen Call {label,".fef8"}
/********************************************/ /********************************************/
/* Group 6: Pointer arithmetic */ /* Group 6: Pointer arithmetic */
@ -964,13 +931,9 @@ pat zre
uses hlreg={const2,0} uses hlreg={const2,0}
gen shld {label,$1} gen shld {label,$1}
pat zrf $1==4 pat zrf $1==4 leaving zer 4
kills ALL
gen Call {label,".zrf4"}
pat zrf $1==8 pat zrf $1==8 leaving zer 8
kills ALL
gen Call {label,".zrf8"}
pat zer $1==2 yields {const2,0} pat zer $1==2 yields {const2,0}
@ -1086,25 +1049,51 @@ kills ALL
gen mvi a,{const1,0} gen mvi a,{const1,0}
Call {label,".cii"} Call {label,".cii"}
pat cfi pat loc loc cfi $2==2
kills ALL leaving loc $1 loc $2 cal ".cfi" asp 4+$1 loe ".fra"
gen Call {label,".cfi"}
pat cif pat loc loc cfi $2==4
kills ALL leaving loc $1 loc $2 cal ".cfi" asp 4+$1 lfr 4
gen Call {label,".cif"}
pat cuf pat loc loc cif $2==4
kills ALL leaving loc $1 cal ".cif4" asp $1-2
gen Call {label,".cuf"}
pat cff pat loc loc cif $1==2 && $2==8
kills ALL with hl_or_de
gen Call {label,".cff"} gen push %1
push %1
push %1 leaving loc $1 cal ".cif8"
pat cfu pat loc loc cif $1==4 && $2==8
kills ALL with hl_or_de hl_or_de
gen Call {label,".cfu"} gen push %2
push %2
push %1 leaving loc $1 cal ".cif8"
pat loc loc cuf $2==4
leaving loc $1 cal ".cuf4" asp $1-2
pat loc loc cuf $1==2 && $2==8
with hl_or_de
gen push %1
push %1
push %1 leaving loc $1 cal ".cuf8"
pat loc loc cuf $1==4 && $2==8
with hl_or_de hl_or_de
gen push %1
push %2
push %1 leaving loc $1 cal ".cuf8"
pat loc loc cff $1==8 && $2==4 leaving cal ".cff4" asp 4
pat loc loc cff $1==4 && $2==8 leaving dup 4 cal ".cff8"
pat loc loc cfu $2==2
leaving loc $1 loc $2 cal ".cfu" asp 4+$1 loe ".fra"
pat loc loc cfu $2==4
leaving loc $1 loc $2 cal ".cfu" asp 4+$1 lfr 4
/*****************************************/ /*****************************************/
/* Group 9: Logical instructions */ /* Group 9: Logical instructions */
@ -1408,12 +1397,10 @@ gen mvi a,{const1,1}
Call {label,".cmi4"} yields de Call {label,".cmi4"} yields de
pat cmf $1==4 pat cmf $1==4
kills ALL leaving cal ".cmf4" asp 8 lfr 2
gen Call {label,".cmf4"}
pat cmf $1==8 pat cmf $1==8
kills ALL leaving cal ".cmf8" asp 16 lfr 2
gen Call {label,".cmf8"}
pat cmu $1==2 pat cmu $1==2
with hl_or_de hl_or_de with hl_or_de hl_or_de

View file

@ -58,7 +58,7 @@ name led
program {EM}/lib/ack/em_led program {EM}/lib/ack/em_led
mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -l* LNAME={PLATFORMDIR}/lib*
mapflag -i SEPID=-b1:0 mapflag -i SEPID=-b1:0
mapflag -fp FLOATS={EM}/{ILIB}fp mapflag -fp FLOATS={PLATFORMDIR}/libfp.a
args {ALIGN} {SEPID?} \ args {ALIGN} {SEPID?} \
({RTS}:.b=-u _i_main) \ ({RTS}:.b=-u _i_main) \
(.e:{HEAD}={PLATFORMDIR}/boot.o) \ (.e:{HEAD}={PLATFORMDIR}/boot.o) \