Adapted for use with improved fp package
This commit is contained in:
parent
b7a61761f3
commit
0a2ee14396
|
@ -139,147 +139,10 @@ prolog(nlocals) full nlocals;
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef NOFLOAT
|
||||
con_float() /* warning only -- AMK */
|
||||
{
|
||||
static int been_here;
|
||||
|
||||
if (argval != 4 && argval != 8)
|
||||
fatal("bad fcon size");
|
||||
fputs(".data4\t", codefile);
|
||||
if (argval == 8)
|
||||
fputs("0,",codefile);
|
||||
fputs("0 !dummy float\n", codefile);
|
||||
if ( !been_here++) {
|
||||
fputs("Warning : dummy float-constant(s)\n", stderr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define CODE_GENERATOR
|
||||
#define IEEEFLOAT
|
||||
|
||||
con_float() {
|
||||
double f;
|
||||
double atof();
|
||||
int i;
|
||||
int j;
|
||||
double frexp();
|
||||
#ifndef OWNFLOAT
|
||||
int sign = 0;
|
||||
int fraction[4] ;
|
||||
#else OWNFLOAT
|
||||
float fl;
|
||||
char *p;
|
||||
#endif OWNFLOAT
|
||||
|
||||
if (argval!= 4 && argval!= 8) {
|
||||
fprintf(stderr,"float constant size = %d\n",argval);
|
||||
fatal("bad fcon size");
|
||||
}
|
||||
fprintf(codefile,"!float %s sz %d\n", str, argval);
|
||||
f = atof(str);
|
||||
if (f == 0) {
|
||||
if (argval == 8) fprintf(codefile, ".data2 0, 0\n");
|
||||
fprintf(codefile, ".data2 0, 0\n");
|
||||
return;
|
||||
}
|
||||
#ifdef OWNFLOAT
|
||||
if (argval == 4) {
|
||||
/* careful: avoid overflow */
|
||||
double ldexp();
|
||||
f = frexp(f, &i);
|
||||
fl = f;
|
||||
fl = frexp(fl,&j);
|
||||
if (i+j > 127) {
|
||||
/* overflow situation */
|
||||
fprintf(codefile, ".data1 0%o, 0377, 0377, 0377 ! overflow\n",
|
||||
f < 0 ? 0377 : 0177);
|
||||
return;
|
||||
}
|
||||
if (i+j < -127) {
|
||||
/* underflow situation */
|
||||
fprintf(codefile, ".data1 0%o, 0200, 0, 0 ! underflow\n",
|
||||
f < 0 ? 0200 : 0);
|
||||
return;
|
||||
}
|
||||
fl = ldexp(fl, i+j);
|
||||
p = (char *) &fl;
|
||||
}
|
||||
else {
|
||||
p = (char *) &f;
|
||||
}
|
||||
fprintf(codefile, ".data1 0%o", *p++ & 0377);
|
||||
for (i = argval-1; i; i--) {
|
||||
fprintf(codefile,",0%o", *p++ & 0377);
|
||||
}
|
||||
#else OWNFLOAT
|
||||
f = frexp(f, &i);
|
||||
if (f < 0) {
|
||||
f = -f;
|
||||
sign = 1;
|
||||
}
|
||||
while (f < 0.5) {
|
||||
f += f;
|
||||
i --;
|
||||
}
|
||||
f = 2*f - 1.0; /* hidden bit */
|
||||
#ifdef IEEEFLOAT
|
||||
if (argval == 4) {
|
||||
#endif IEEEFLOAT
|
||||
i = (i + 128) & 0377;
|
||||
fraction[0] = (sign << 15) | (i << 7);
|
||||
for (j = 6; j>= 0; j--) {
|
||||
f *= 2;
|
||||
if (f >= 1.0) {
|
||||
f -= 1.0;
|
||||
fraction[0] |= (1 << j);
|
||||
}
|
||||
}
|
||||
#ifdef IEEEFLOAT
|
||||
}
|
||||
else {
|
||||
i = (i + 1024) & 03777;
|
||||
fraction[0] = (sign << 15) | (i << 4);
|
||||
for (j = 3; j>= 0; j--) {
|
||||
f *= 2;
|
||||
if (f >= 1.0) {
|
||||
fraction[0] |= (1 << j);
|
||||
f -= 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif IEEEFLOAT
|
||||
for (i = 1; i < argval / 2; i++) {
|
||||
fraction[i] = 0;
|
||||
for (j = 15; j>= 0; j--) {
|
||||
f *= 2;
|
||||
if (f >= 1.0) {
|
||||
fraction[i] |= (1 << j);
|
||||
f -= 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f >= 0.5) {
|
||||
for (i = argval/2 - 1; i >= 0; i--) {
|
||||
for (j = 0; j < 16; j++) {
|
||||
if (fraction[i] & (1 << j)) {
|
||||
fraction[i] &= ~(1 << j);
|
||||
}
|
||||
else {
|
||||
fraction[i] |= (1 << j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j != 16) break;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < argval/2; i++) {
|
||||
fprintf(codefile,
|
||||
i != 0 ? ", 0%o, 0%o" : ".data1 0%o, 0%o",
|
||||
(fraction[i]>>8)&0377,
|
||||
fraction[i]&0377);
|
||||
}
|
||||
#endif OWNFLOAT
|
||||
putc('\n', codefile);
|
||||
}
|
||||
#endif
|
||||
#define FL_MSL_AT_LOW_ADDRESS 0
|
||||
#define FL_MSW_AT_LOW_ADDRESS 0
|
||||
#define FL_MSB_AT_LOW_ADDRESS 0
|
||||
#include <con_float>
|
||||
|
||||
|
|
|
@ -1324,69 +1324,20 @@ with const4+fitcon GENREG yields {imS, %2, "LSR", %1.num}
|
|||
* *
|
||||
************************************************************************/
|
||||
|
||||
pat adf $1==8
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".adf8" asp 16 lfr 4 loi 8
|
||||
pat adf $1==4
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".adf4" asp 8 lfr 4
|
||||
|
||||
pat sbf $1==8
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".sbf8" asp 16 lfr 4 loi 8
|
||||
pat sbf $1==4
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".sbf4" asp 8 lfr 4
|
||||
|
||||
pat mlf $1==8
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".mlf8" asp 16 lfr 4 loi 8
|
||||
pat mlf $1==4
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".mlf4" asp 8 lfr 4
|
||||
|
||||
pat dvf $1==8
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".dvf8" asp 8
|
||||
pat dvf $1==4
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".dvf4" asp 4
|
||||
|
||||
pat ngf $1==8
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".ngf8"
|
||||
pat ngf $1==4
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".ngf4"
|
||||
|
||||
pat fif $1==8
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".fif8"
|
||||
pat fif $1==4
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving cal ".fif4"
|
||||
|
||||
/* the next two need a 4 byte hole on the stack */
|
||||
pat ldl fef $2==8
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving loc 0 ldl $1 cal ".fef8"
|
||||
pat lol fef $2==4
|
||||
with STACK
|
||||
kills ALL
|
||||
leaving loc 0 lol $1 cal ".fef4"
|
||||
pat adf $1==4 leaving cal ".adf4" asp 4
|
||||
pat adf $1==8 leaving cal ".adf8" asp 8
|
||||
pat sbf $1==4 leaving cal ".sbf4" asp 4
|
||||
pat sbf $1==8 leaving cal ".sbf8" asp 8
|
||||
pat mlf $1==4 leaving cal ".mlf4" asp 4
|
||||
pat mlf $1==8 leaving cal ".mlf8" asp 8
|
||||
pat dvf $1==4 leaving cal ".dvf4" asp 4
|
||||
pat dvf $1==8 leaving cal ".dvf8" asp 8
|
||||
pat ngf $1==4 leaving cal ".ngf4"
|
||||
pat ngf $1==8 leaving cal ".ngf8"
|
||||
pat fif $1==4 leaving lor 1 cal ".fif4" asp 4
|
||||
pat fif $1==8 leaving lor 1 cal ".fif8" asp 4
|
||||
pat fef $1==4 leaving lor 1 adp 0-4 cal ".fef4"
|
||||
pat fef $1==8 leaving lor 1 adp 0-4 cal ".fef8"
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
|
@ -1495,21 +1446,15 @@ pat loc loc cii ($1 > 2)
|
|||
pat cui
|
||||
with address +REGcon address + REGcon
|
||||
|
||||
pat loc loc cif $1==4 && $2==4 leaving loc 4 cal ".cif4" asp 8 lfr 4
|
||||
pat loc loc cif $1==4 && $2==8 leaving loc 4 cal ".cif8" asp 8 lfr 4 loi 8
|
||||
pat loc loc cif $1==4 && $2==4 leaving loc 4 cal ".cif4" asp 4
|
||||
pat loc loc cif $1==4 && $2==8 leaving loc 4 cal ".cif8"
|
||||
|
||||
pat loc loc cuf $1==4 && $2==4 leaving loc 4 cal ".cuf4" asp 8 lfr 4
|
||||
pat loc loc cuf $1==4 && $2==4 leaving loc 4 cal ".cuf4" asp 4
|
||||
pat loc loc cuf $1==4 && $2==8 leaving loc 4 cal ".cuf8"
|
||||
|
||||
pat loc loc cfi $1==8 && $2==4
|
||||
leaving loc $1 loc $2 cal ".cfi" asp 16 lfr 4
|
||||
pat loc loc cfi $1==4 && $2==4
|
||||
leaving loc $1 loc $2 cal ".cfi" asp 12 lfr 4
|
||||
pat loc loc cfi leaving loc $1 loc $2 cal ".cfi" asp 8+($1-4)
|
||||
|
||||
pat loc loc cfu $1==8 && $2==4
|
||||
leaving loc $1 loc $2 cal ".cfu" asp 16 lfr 4
|
||||
pat loc loc cfu $1==4 && $2==4
|
||||
leaving loc $1 loc $2 cal ".cfu" asp 12 lfr 4
|
||||
pat loc loc cfu leaving loc $1 loc $2 cal ".cfu" asp 8+($1-4)
|
||||
|
||||
pat loc loc cff $1==8 && $2==4 leaving cal ".cff4" asp 4
|
||||
|
||||
|
|
Loading…
Reference in a new issue