fixed some problems, and added floating point library
This commit is contained in:
parent
ad65ffcf9b
commit
e2037c2e4b
|
@ -40,6 +40,7 @@ con_mult(sz) word sz; {
|
|||
fprintf(codefile,".data4 %s\n",str);
|
||||
}
|
||||
|
||||
#ifdef NOFLOAT
|
||||
con_float() {
|
||||
|
||||
static int been_here;
|
||||
|
@ -54,6 +55,91 @@ static int been_here;
|
|||
fputs("Warning : dummy float-constant(s)\n", stderr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define IEEEFLOAT
|
||||
|
||||
con_float() {
|
||||
double f;
|
||||
double atof();
|
||||
float fl;
|
||||
int i;
|
||||
#ifndef OWNFLOAT
|
||||
double f1;
|
||||
double frexp(), modf();
|
||||
int j;
|
||||
int sign = 0;
|
||||
int fraction ;
|
||||
#else OWNFLOAT
|
||||
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);
|
||||
#ifdef OWNFLOAT
|
||||
if (argval == 4) {
|
||||
fl = f;
|
||||
p = (char *) &fl;
|
||||
}
|
||||
else {
|
||||
p = (char *) &f;
|
||||
}
|
||||
fprintf(codefile, ".data1 0%o", *p++ & 0377);
|
||||
for (i = argval-2; i; i--) {
|
||||
fprintf(codefile,",0%o", *p++ & 0377);
|
||||
}
|
||||
#else OWNFLOAT
|
||||
f = frexp(f, &i);
|
||||
if (f < 0) {
|
||||
f = -f;
|
||||
sign = 1;
|
||||
}
|
||||
if (f == 0) {
|
||||
if (argval == 8) fprintf(codefile, ".data2 0, 0\n");
|
||||
fprintf(codefile, ".data2 0, 0\n");
|
||||
return;
|
||||
}
|
||||
while (f < 0.5) {
|
||||
f += f;
|
||||
i --;
|
||||
}
|
||||
f = modf(2 * f, &f1); /* hidden bit */
|
||||
#ifdef IEEEFLOAT
|
||||
if (argval == 4) {
|
||||
#endif IEEEFLOAT
|
||||
i = (i + 128) & 0377;
|
||||
fraction = (sign << 15) | (i << 7);
|
||||
for (j = 6; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
#ifdef IEEEFLOAT
|
||||
}
|
||||
else {
|
||||
i = (i + 1024) & 03777;
|
||||
fraction = (sign << 15) | (i << 4);
|
||||
for (j = 3; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
}
|
||||
#endif IEEEFLOAT
|
||||
fprintf(codefile, ".data1 0%o, 0%o", (fraction>>8)&0377, fraction&0377);
|
||||
for (i = argval / 2 - 1; i; i--) {
|
||||
fraction = 0;
|
||||
for (j = 15; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
fprintf(codefile, ", 0%o, 0%o", (fraction>>8)&0377, fraction&0377);
|
||||
}
|
||||
#endif OWNFLOAT
|
||||
putc('\n', codefile);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MOVEM_LIMIT 2
|
||||
/* If #registers to be saved exceeds MOVEM_LIMIT, we
|
||||
|
|
|
@ -707,6 +707,14 @@ from memory1
|
|||
uses DD_REG = {const, 0}
|
||||
gen move_b %1, %a yields %a
|
||||
|
||||
from memory2
|
||||
uses DD_REG
|
||||
gen move_w %1, %a yields {dreg2, %a}
|
||||
|
||||
from memory1
|
||||
uses DD_REG
|
||||
gen move_b %1, %a yields {dreg1, %a}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -724,6 +732,9 @@ pat lol inreg($1)==reg_pointer
|
|||
pat lil inreg($1)==reg_pointer
|
||||
kills pre_post %reg==regvar($1, reg_pointer)
|
||||
yields {indirect4, regvar($1, reg_pointer)}
|
||||
pat lil inreg($1)==reg_any
|
||||
uses AA_REG = { LOCAL, $1}
|
||||
yields {indirect4, %a}
|
||||
|
||||
pat stl inreg($1)==reg_any
|
||||
with any4
|
||||
|
@ -754,6 +765,15 @@ with any4
|
|||
with exact STACK
|
||||
kills allexceptcon
|
||||
gen move {post_inc4, sp}, {indirect4, regvar($1, reg_pointer)}
|
||||
pat sil inreg($1)==reg_any
|
||||
with any4
|
||||
kills allexceptcon
|
||||
uses AA_REG = {LOCAL, $1}
|
||||
gen move %1, {indirect4, %a}
|
||||
with exact STACK
|
||||
kills allexceptcon
|
||||
uses AA_REG = {LOCAL, $1}
|
||||
gen move {post_inc4, sp}, {indirect4, %a}
|
||||
|
||||
|
||||
pat lol sbi stl $1==$3 && $2==4 && inreg($1)==reg_any
|
||||
|
@ -1758,12 +1778,20 @@ with any4 any4
|
|||
kills all_indir, LOCAL %bd==$1
|
||||
gen move %1, {LOCAL, $1}
|
||||
move %2, {LOCAL, $1+4}
|
||||
with exact STACK
|
||||
kills all_indir, LOCAL %bd==$1
|
||||
gen move_l {post_inc4, sp}, {LOCAL,$1}
|
||||
move_l {post_inc4, sp}, {LOCAL,$1+4}
|
||||
|
||||
pat sde
|
||||
with any4 any4
|
||||
kills posextern
|
||||
gen move %1, {absolute4, $1}
|
||||
move %2, {absolute4, $1+4}
|
||||
with exact STACK
|
||||
kills posextern
|
||||
gen move_l {post_inc4, sp}, {absolute4,$1}
|
||||
move_l {post_inc4, sp}, {absolute4,$1+4}
|
||||
|
||||
pat sdf
|
||||
with A_REG any4 any4
|
||||
|
@ -1981,20 +2009,34 @@ with D_REG DD_REG
|
|||
|
||||
/************************************************
|
||||
* Group 5: floating point arithmetic *
|
||||
* *
|
||||
* is not available on 68000, 68010 or 68020 *
|
||||
* so traps will be generated *
|
||||
************************************************/
|
||||
|
||||
pat adf leaving loc 18 trp
|
||||
pat sbf leaving loc 18 trp
|
||||
pat mlf leaving loc 18 trp
|
||||
pat dvf leaving loc 18 trp
|
||||
pat ngf leaving loc 18 trp
|
||||
pat fif leaving loc 18 trp
|
||||
pat fef leaving loc 18 trp
|
||||
|
||||
|
||||
/* Floating point stuff
|
||||
* Arithmetic instructions
|
||||
*/
|
||||
|
||||
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 cal ".fif4"
|
||||
pat fif $1==8 leaving cal ".fif8"
|
||||
pat fef $1==4 leaving dup 4 cal ".fef4"
|
||||
pat fef $1==8
|
||||
kills ALL
|
||||
gen
|
||||
move_l {post_inc4, sp}, d0
|
||||
move_l {post_inc4, sp}, d1
|
||||
move_l d0, {pre_dec4, sp}
|
||||
move_l d1, {pre_dec4, sp}
|
||||
move_l d0, {pre_dec4, sp}
|
||||
leaving cal ".fef8"
|
||||
|
||||
/************************************************
|
||||
* Group 6: pointer arithmetic *
|
||||
|
@ -2168,13 +2210,9 @@ with STACK
|
|||
dbf %a, {slabel, 1b}
|
||||
|
||||
|
||||
pat zrf leaving loc 18 trp
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
* Group 8: convert instructions *
|
||||
* for float conversions traps are generated *
|
||||
************************************************/
|
||||
|
||||
|
||||
|
@ -2193,12 +2231,24 @@ pat ciu leaving cuu
|
|||
|
||||
pat cui leaving cuu
|
||||
|
||||
pat cfi leaving loc 18 trp
|
||||
pat cif leaving loc 18 trp
|
||||
pat cfu leaving loc 18 trp
|
||||
pat cuf leaving loc 18 trp
|
||||
pat cff leaving loc 18 trp
|
||||
|
||||
/*
|
||||
* Floating point stuff
|
||||
* Conversion
|
||||
*/
|
||||
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 4
|
||||
pat loc loc cuf $1==4 && $2==8 leaving loc 4 cal ".cuf8"
|
||||
pat loc loc cfi leaving loc $1 loc $2 cal ".cfi" asp 8+($1-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
|
||||
pat loc loc cff $1==4 && $2==8
|
||||
kills ALL
|
||||
gen
|
||||
move_l {indirect4, sp}, d0
|
||||
clr_l {indirect4, sp}
|
||||
move_l d0, {pre_dec4, sp}
|
||||
leaving cal ".cff8"
|
||||
|
||||
/************************************************
|
||||
* Group 9: logical instructions *
|
||||
|
@ -2514,9 +2564,18 @@ pat tne call txx("bne", "bne")
|
|||
pat tge call txx("bge", "bcc")
|
||||
pat tgt call txx("bgt", "bhi")
|
||||
|
||||
pat cmf leaving loc 18 trp
|
||||
|
||||
/*
|
||||
* Floating point
|
||||
* Comparision
|
||||
*/
|
||||
|
||||
pat cmf $1==4 leaving cal ".cmf4" asp 8 lfr 4
|
||||
pat cmf $1==8 leaving cal ".cmf8" asp 16 lfr 4
|
||||
/*
|
||||
* Floating Point
|
||||
* Zero Constants
|
||||
*/
|
||||
pat zrf leaving zer $1
|
||||
|
||||
/************************************************
|
||||
* Group 13: branch instructions *
|
||||
|
|
|
@ -40,6 +40,7 @@ con_mult(sz) word sz; {
|
|||
fprintf(codefile,".data4 %s\n",str);
|
||||
}
|
||||
|
||||
#ifdef NOFLOAT
|
||||
con_float() {
|
||||
|
||||
static int been_here;
|
||||
|
@ -54,6 +55,91 @@ static int been_here;
|
|||
fputs("Warning : dummy float-constant(s)\n", stderr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define IEEEFLOAT
|
||||
|
||||
con_float() {
|
||||
double f;
|
||||
double atof();
|
||||
float fl;
|
||||
int i;
|
||||
#ifndef OWNFLOAT
|
||||
double f1;
|
||||
double frexp(), modf();
|
||||
int j;
|
||||
int sign = 0;
|
||||
int fraction ;
|
||||
#else OWNFLOAT
|
||||
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);
|
||||
#ifdef OWNFLOAT
|
||||
if (argval == 4) {
|
||||
fl = f;
|
||||
p = (char *) &fl;
|
||||
}
|
||||
else {
|
||||
p = (char *) &f;
|
||||
}
|
||||
fprintf(codefile, ".data1 0%o", *p++ & 0377);
|
||||
for (i = argval-2; i; i--) {
|
||||
fprintf(codefile,",0%o", *p++ & 0377);
|
||||
}
|
||||
#else OWNFLOAT
|
||||
f = frexp(f, &i);
|
||||
if (f < 0) {
|
||||
f = -f;
|
||||
sign = 1;
|
||||
}
|
||||
if (f == 0) {
|
||||
if (argval == 8) fprintf(codefile, ".data2 0, 0\n");
|
||||
fprintf(codefile, ".data2 0, 0\n");
|
||||
return;
|
||||
}
|
||||
while (f < 0.5) {
|
||||
f += f;
|
||||
i --;
|
||||
}
|
||||
f = modf(2 * f, &f1); /* hidden bit */
|
||||
#ifdef IEEEFLOAT
|
||||
if (argval == 4) {
|
||||
#endif IEEEFLOAT
|
||||
i = (i + 128) & 0377;
|
||||
fraction = (sign << 15) | (i << 7);
|
||||
for (j = 6; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
#ifdef IEEEFLOAT
|
||||
}
|
||||
else {
|
||||
i = (i + 1024) & 03777;
|
||||
fraction = (sign << 15) | (i << 4);
|
||||
for (j = 3; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
}
|
||||
#endif IEEEFLOAT
|
||||
fprintf(codefile, ".data1 0%o, 0%o", (fraction>>8)&0377, fraction&0377);
|
||||
for (i = argval / 2 - 1; i; i--) {
|
||||
fraction = 0;
|
||||
for (j = 15; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
fprintf(codefile, ", 0%o, 0%o", (fraction>>8)&0377, fraction&0377);
|
||||
}
|
||||
#endif OWNFLOAT
|
||||
putc('\n', codefile);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MOVEM_LIMIT 2
|
||||
/* If #registers to be saved exceeds MOVEM_LIMIT, we
|
||||
|
|
|
@ -707,6 +707,14 @@ from memory1
|
|||
uses DD_REG = {const, 0}
|
||||
gen move_b %1, %a yields %a
|
||||
|
||||
from memory2
|
||||
uses DD_REG
|
||||
gen move_w %1, %a yields {dreg2, %a}
|
||||
|
||||
from memory1
|
||||
uses DD_REG
|
||||
gen move_b %1, %a yields {dreg1, %a}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -724,6 +732,9 @@ pat lol inreg($1)==reg_pointer
|
|||
pat lil inreg($1)==reg_pointer
|
||||
kills pre_post %reg==regvar($1, reg_pointer)
|
||||
yields {indirect4, regvar($1, reg_pointer)}
|
||||
pat lil inreg($1)==reg_any
|
||||
uses AA_REG = { LOCAL, $1}
|
||||
yields {indirect4, %a}
|
||||
|
||||
pat stl inreg($1)==reg_any
|
||||
with any4
|
||||
|
@ -754,6 +765,15 @@ with any4
|
|||
with exact STACK
|
||||
kills allexceptcon
|
||||
gen move {post_inc4, sp}, {indirect4, regvar($1, reg_pointer)}
|
||||
pat sil inreg($1)==reg_any
|
||||
with any4
|
||||
kills allexceptcon
|
||||
uses AA_REG = {LOCAL, $1}
|
||||
gen move %1, {indirect4, %a}
|
||||
with exact STACK
|
||||
kills allexceptcon
|
||||
uses AA_REG = {LOCAL, $1}
|
||||
gen move {post_inc4, sp}, {indirect4, %a}
|
||||
|
||||
|
||||
pat lol sbi stl $1==$3 && $2==4 && inreg($1)==reg_any
|
||||
|
@ -1758,12 +1778,20 @@ with any4 any4
|
|||
kills all_indir, LOCAL %bd==$1
|
||||
gen move %1, {LOCAL, $1}
|
||||
move %2, {LOCAL, $1+4}
|
||||
with exact STACK
|
||||
kills all_indir, LOCAL %bd==$1
|
||||
gen move_l {post_inc4, sp}, {LOCAL,$1}
|
||||
move_l {post_inc4, sp}, {LOCAL,$1+4}
|
||||
|
||||
pat sde
|
||||
with any4 any4
|
||||
kills posextern
|
||||
gen move %1, {absolute4, $1}
|
||||
move %2, {absolute4, $1+4}
|
||||
with exact STACK
|
||||
kills posextern
|
||||
gen move_l {post_inc4, sp}, {absolute4,$1}
|
||||
move_l {post_inc4, sp}, {absolute4,$1+4}
|
||||
|
||||
pat sdf
|
||||
with A_REG any4 any4
|
||||
|
@ -1981,20 +2009,34 @@ with D_REG DD_REG
|
|||
|
||||
/************************************************
|
||||
* Group 5: floating point arithmetic *
|
||||
* *
|
||||
* is not available on 68000, 68010 or 68020 *
|
||||
* so traps will be generated *
|
||||
************************************************/
|
||||
|
||||
pat adf leaving loc 18 trp
|
||||
pat sbf leaving loc 18 trp
|
||||
pat mlf leaving loc 18 trp
|
||||
pat dvf leaving loc 18 trp
|
||||
pat ngf leaving loc 18 trp
|
||||
pat fif leaving loc 18 trp
|
||||
pat fef leaving loc 18 trp
|
||||
|
||||
|
||||
/* Floating point stuff
|
||||
* Arithmetic instructions
|
||||
*/
|
||||
|
||||
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 cal ".fif4"
|
||||
pat fif $1==8 leaving cal ".fif8"
|
||||
pat fef $1==4 leaving dup 4 cal ".fef4"
|
||||
pat fef $1==8
|
||||
kills ALL
|
||||
gen
|
||||
move_l {post_inc4, sp}, d0
|
||||
move_l {post_inc4, sp}, d1
|
||||
move_l d0, {pre_dec4, sp}
|
||||
move_l d1, {pre_dec4, sp}
|
||||
move_l d0, {pre_dec4, sp}
|
||||
leaving cal ".fef8"
|
||||
|
||||
/************************************************
|
||||
* Group 6: pointer arithmetic *
|
||||
|
@ -2168,13 +2210,9 @@ with STACK
|
|||
dbf %a, {slabel, 1b}
|
||||
|
||||
|
||||
pat zrf leaving loc 18 trp
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
* Group 8: convert instructions *
|
||||
* for float conversions traps are generated *
|
||||
************************************************/
|
||||
|
||||
|
||||
|
@ -2193,12 +2231,24 @@ pat ciu leaving cuu
|
|||
|
||||
pat cui leaving cuu
|
||||
|
||||
pat cfi leaving loc 18 trp
|
||||
pat cif leaving loc 18 trp
|
||||
pat cfu leaving loc 18 trp
|
||||
pat cuf leaving loc 18 trp
|
||||
pat cff leaving loc 18 trp
|
||||
|
||||
/*
|
||||
* Floating point stuff
|
||||
* Conversion
|
||||
*/
|
||||
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 4
|
||||
pat loc loc cuf $1==4 && $2==8 leaving loc 4 cal ".cuf8"
|
||||
pat loc loc cfi leaving loc $1 loc $2 cal ".cfi" asp 8+($1-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
|
||||
pat loc loc cff $1==4 && $2==8
|
||||
kills ALL
|
||||
gen
|
||||
move_l {indirect4, sp}, d0
|
||||
clr_l {indirect4, sp}
|
||||
move_l d0, {pre_dec4, sp}
|
||||
leaving cal ".cff8"
|
||||
|
||||
/************************************************
|
||||
* Group 9: logical instructions *
|
||||
|
@ -2514,9 +2564,18 @@ pat tne call txx("bne", "bne")
|
|||
pat tge call txx("bge", "bcc")
|
||||
pat tgt call txx("bgt", "bhi")
|
||||
|
||||
pat cmf leaving loc 18 trp
|
||||
|
||||
/*
|
||||
* Floating point
|
||||
* Comparision
|
||||
*/
|
||||
|
||||
pat cmf $1==4 leaving cal ".cmf4" asp 8 lfr 4
|
||||
pat cmf $1==8 leaving cal ".cmf8" asp 16 lfr 4
|
||||
/*
|
||||
* Floating Point
|
||||
* Zero Constants
|
||||
*/
|
||||
pat zrf leaving zer $1
|
||||
|
||||
/************************************************
|
||||
* Group 13: branch instructions *
|
||||
|
|
|
@ -40,6 +40,7 @@ con_mult(sz) word sz; {
|
|||
fprintf(codefile,".data4 %s\n",str);
|
||||
}
|
||||
|
||||
#ifdef NOFLOAT
|
||||
con_float() {
|
||||
|
||||
static int been_here;
|
||||
|
@ -54,6 +55,91 @@ static int been_here;
|
|||
fputs("Warning : dummy float-constant(s)\n", stderr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define IEEEFLOAT
|
||||
|
||||
con_float() {
|
||||
double f;
|
||||
double atof();
|
||||
float fl;
|
||||
int i;
|
||||
#ifndef OWNFLOAT
|
||||
double f1;
|
||||
double frexp(), modf();
|
||||
int j;
|
||||
int sign = 0;
|
||||
int fraction ;
|
||||
#else OWNFLOAT
|
||||
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);
|
||||
#ifdef OWNFLOAT
|
||||
if (argval == 4) {
|
||||
fl = f;
|
||||
p = (char *) &fl;
|
||||
}
|
||||
else {
|
||||
p = (char *) &f;
|
||||
}
|
||||
fprintf(codefile, ".data1 0%o", *p++ & 0377);
|
||||
for (i = argval-2; i; i--) {
|
||||
fprintf(codefile,",0%o", *p++ & 0377);
|
||||
}
|
||||
#else OWNFLOAT
|
||||
f = frexp(f, &i);
|
||||
if (f < 0) {
|
||||
f = -f;
|
||||
sign = 1;
|
||||
}
|
||||
if (f == 0) {
|
||||
if (argval == 8) fprintf(codefile, ".data2 0, 0\n");
|
||||
fprintf(codefile, ".data2 0, 0\n");
|
||||
return;
|
||||
}
|
||||
while (f < 0.5) {
|
||||
f += f;
|
||||
i --;
|
||||
}
|
||||
f = modf(2 * f, &f1); /* hidden bit */
|
||||
#ifdef IEEEFLOAT
|
||||
if (argval == 4) {
|
||||
#endif IEEEFLOAT
|
||||
i = (i + 128) & 0377;
|
||||
fraction = (sign << 15) | (i << 7);
|
||||
for (j = 6; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
#ifdef IEEEFLOAT
|
||||
}
|
||||
else {
|
||||
i = (i + 1024) & 03777;
|
||||
fraction = (sign << 15) | (i << 4);
|
||||
for (j = 3; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
}
|
||||
#endif IEEEFLOAT
|
||||
fprintf(codefile, ".data1 0%o, 0%o", (fraction>>8)&0377, fraction&0377);
|
||||
for (i = argval / 2 - 1; i; i--) {
|
||||
fraction = 0;
|
||||
for (j = 15; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
fprintf(codefile, ", 0%o, 0%o", (fraction>>8)&0377, fraction&0377);
|
||||
}
|
||||
#endif OWNFLOAT
|
||||
putc('\n', codefile);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MOVEM_LIMIT 2
|
||||
/* If #registers to be saved exceeds MOVEM_LIMIT, we
|
||||
|
|
|
@ -707,6 +707,14 @@ from memory1
|
|||
uses DD_REG = {const, 0}
|
||||
gen move_b %1, %a yields %a
|
||||
|
||||
from memory2
|
||||
uses DD_REG
|
||||
gen move_w %1, %a yields {dreg2, %a}
|
||||
|
||||
from memory1
|
||||
uses DD_REG
|
||||
gen move_b %1, %a yields {dreg1, %a}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -724,6 +732,9 @@ pat lol inreg($1)==reg_pointer
|
|||
pat lil inreg($1)==reg_pointer
|
||||
kills pre_post %reg==regvar($1, reg_pointer)
|
||||
yields {indirect4, regvar($1, reg_pointer)}
|
||||
pat lil inreg($1)==reg_any
|
||||
uses AA_REG = { LOCAL, $1}
|
||||
yields {indirect4, %a}
|
||||
|
||||
pat stl inreg($1)==reg_any
|
||||
with any4
|
||||
|
@ -754,6 +765,15 @@ with any4
|
|||
with exact STACK
|
||||
kills allexceptcon
|
||||
gen move {post_inc4, sp}, {indirect4, regvar($1, reg_pointer)}
|
||||
pat sil inreg($1)==reg_any
|
||||
with any4
|
||||
kills allexceptcon
|
||||
uses AA_REG = {LOCAL, $1}
|
||||
gen move %1, {indirect4, %a}
|
||||
with exact STACK
|
||||
kills allexceptcon
|
||||
uses AA_REG = {LOCAL, $1}
|
||||
gen move {post_inc4, sp}, {indirect4, %a}
|
||||
|
||||
|
||||
pat lol sbi stl $1==$3 && $2==4 && inreg($1)==reg_any
|
||||
|
@ -1758,12 +1778,20 @@ with any4 any4
|
|||
kills all_indir, LOCAL %bd==$1
|
||||
gen move %1, {LOCAL, $1}
|
||||
move %2, {LOCAL, $1+4}
|
||||
with exact STACK
|
||||
kills all_indir, LOCAL %bd==$1
|
||||
gen move_l {post_inc4, sp}, {LOCAL,$1}
|
||||
move_l {post_inc4, sp}, {LOCAL,$1+4}
|
||||
|
||||
pat sde
|
||||
with any4 any4
|
||||
kills posextern
|
||||
gen move %1, {absolute4, $1}
|
||||
move %2, {absolute4, $1+4}
|
||||
with exact STACK
|
||||
kills posextern
|
||||
gen move_l {post_inc4, sp}, {absolute4,$1}
|
||||
move_l {post_inc4, sp}, {absolute4,$1+4}
|
||||
|
||||
pat sdf
|
||||
with A_REG any4 any4
|
||||
|
@ -1981,20 +2009,34 @@ with D_REG DD_REG
|
|||
|
||||
/************************************************
|
||||
* Group 5: floating point arithmetic *
|
||||
* *
|
||||
* is not available on 68000, 68010 or 68020 *
|
||||
* so traps will be generated *
|
||||
************************************************/
|
||||
|
||||
pat adf leaving loc 18 trp
|
||||
pat sbf leaving loc 18 trp
|
||||
pat mlf leaving loc 18 trp
|
||||
pat dvf leaving loc 18 trp
|
||||
pat ngf leaving loc 18 trp
|
||||
pat fif leaving loc 18 trp
|
||||
pat fef leaving loc 18 trp
|
||||
|
||||
|
||||
/* Floating point stuff
|
||||
* Arithmetic instructions
|
||||
*/
|
||||
|
||||
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 cal ".fif4"
|
||||
pat fif $1==8 leaving cal ".fif8"
|
||||
pat fef $1==4 leaving dup 4 cal ".fef4"
|
||||
pat fef $1==8
|
||||
kills ALL
|
||||
gen
|
||||
move_l {post_inc4, sp}, d0
|
||||
move_l {post_inc4, sp}, d1
|
||||
move_l d0, {pre_dec4, sp}
|
||||
move_l d1, {pre_dec4, sp}
|
||||
move_l d0, {pre_dec4, sp}
|
||||
leaving cal ".fef8"
|
||||
|
||||
/************************************************
|
||||
* Group 6: pointer arithmetic *
|
||||
|
@ -2168,13 +2210,9 @@ with STACK
|
|||
dbf %a, {slabel, 1b}
|
||||
|
||||
|
||||
pat zrf leaving loc 18 trp
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
* Group 8: convert instructions *
|
||||
* for float conversions traps are generated *
|
||||
************************************************/
|
||||
|
||||
|
||||
|
@ -2193,12 +2231,24 @@ pat ciu leaving cuu
|
|||
|
||||
pat cui leaving cuu
|
||||
|
||||
pat cfi leaving loc 18 trp
|
||||
pat cif leaving loc 18 trp
|
||||
pat cfu leaving loc 18 trp
|
||||
pat cuf leaving loc 18 trp
|
||||
pat cff leaving loc 18 trp
|
||||
|
||||
/*
|
||||
* Floating point stuff
|
||||
* Conversion
|
||||
*/
|
||||
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 4
|
||||
pat loc loc cuf $1==4 && $2==8 leaving loc 4 cal ".cuf8"
|
||||
pat loc loc cfi leaving loc $1 loc $2 cal ".cfi" asp 8+($1-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
|
||||
pat loc loc cff $1==4 && $2==8
|
||||
kills ALL
|
||||
gen
|
||||
move_l {indirect4, sp}, d0
|
||||
clr_l {indirect4, sp}
|
||||
move_l d0, {pre_dec4, sp}
|
||||
leaving cal ".cff8"
|
||||
|
||||
/************************************************
|
||||
* Group 9: logical instructions *
|
||||
|
@ -2514,9 +2564,18 @@ pat tne call txx("bne", "bne")
|
|||
pat tge call txx("bge", "bcc")
|
||||
pat tgt call txx("bgt", "bhi")
|
||||
|
||||
pat cmf leaving loc 18 trp
|
||||
|
||||
/*
|
||||
* Floating point
|
||||
* Comparision
|
||||
*/
|
||||
|
||||
pat cmf $1==4 leaving cal ".cmf4" asp 8 lfr 4
|
||||
pat cmf $1==8 leaving cal ".cmf8" asp 16 lfr 4
|
||||
/*
|
||||
* Floating Point
|
||||
* Zero Constants
|
||||
*/
|
||||
pat zrf leaving zer $1
|
||||
|
||||
/************************************************
|
||||
* Group 13: branch instructions *
|
||||
|
|
|
@ -40,6 +40,7 @@ con_mult(sz) word sz; {
|
|||
fprintf(codefile,".data4 %s\n",str);
|
||||
}
|
||||
|
||||
#ifdef NOFLOAT
|
||||
con_float() {
|
||||
|
||||
static int been_here;
|
||||
|
@ -54,6 +55,91 @@ static int been_here;
|
|||
fputs("Warning : dummy float-constant(s)\n", stderr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define IEEEFLOAT
|
||||
|
||||
con_float() {
|
||||
double f;
|
||||
double atof();
|
||||
float fl;
|
||||
int i;
|
||||
#ifndef OWNFLOAT
|
||||
double f1;
|
||||
double frexp(), modf();
|
||||
int j;
|
||||
int sign = 0;
|
||||
int fraction ;
|
||||
#else OWNFLOAT
|
||||
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);
|
||||
#ifdef OWNFLOAT
|
||||
if (argval == 4) {
|
||||
fl = f;
|
||||
p = (char *) &fl;
|
||||
}
|
||||
else {
|
||||
p = (char *) &f;
|
||||
}
|
||||
fprintf(codefile, ".data1 0%o", *p++ & 0377);
|
||||
for (i = argval-2; i; i--) {
|
||||
fprintf(codefile,",0%o", *p++ & 0377);
|
||||
}
|
||||
#else OWNFLOAT
|
||||
f = frexp(f, &i);
|
||||
if (f < 0) {
|
||||
f = -f;
|
||||
sign = 1;
|
||||
}
|
||||
if (f == 0) {
|
||||
if (argval == 8) fprintf(codefile, ".data2 0, 0\n");
|
||||
fprintf(codefile, ".data2 0, 0\n");
|
||||
return;
|
||||
}
|
||||
while (f < 0.5) {
|
||||
f += f;
|
||||
i --;
|
||||
}
|
||||
f = modf(2 * f, &f1); /* hidden bit */
|
||||
#ifdef IEEEFLOAT
|
||||
if (argval == 4) {
|
||||
#endif IEEEFLOAT
|
||||
i = (i + 128) & 0377;
|
||||
fraction = (sign << 15) | (i << 7);
|
||||
for (j = 6; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
#ifdef IEEEFLOAT
|
||||
}
|
||||
else {
|
||||
i = (i + 1024) & 03777;
|
||||
fraction = (sign << 15) | (i << 4);
|
||||
for (j = 3; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
}
|
||||
#endif IEEEFLOAT
|
||||
fprintf(codefile, ".data1 0%o, 0%o", (fraction>>8)&0377, fraction&0377);
|
||||
for (i = argval / 2 - 1; i; i--) {
|
||||
fraction = 0;
|
||||
for (j = 15; j>= 0; j--) {
|
||||
if (f >= 0.5) fraction |= (1 << j);
|
||||
f = modf(2*f, &f1);
|
||||
}
|
||||
fprintf(codefile, ", 0%o, 0%o", (fraction>>8)&0377, fraction&0377);
|
||||
}
|
||||
#endif OWNFLOAT
|
||||
putc('\n', codefile);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MOVEM_LIMIT 2
|
||||
/* If #registers to be saved exceeds MOVEM_LIMIT, we
|
||||
|
|
|
@ -707,6 +707,14 @@ from memory1
|
|||
uses DD_REG = {const, 0}
|
||||
gen move_b %1, %a yields %a
|
||||
|
||||
from memory2
|
||||
uses DD_REG
|
||||
gen move_w %1, %a yields {dreg2, %a}
|
||||
|
||||
from memory1
|
||||
uses DD_REG
|
||||
gen move_b %1, %a yields {dreg1, %a}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -724,6 +732,9 @@ pat lol inreg($1)==reg_pointer
|
|||
pat lil inreg($1)==reg_pointer
|
||||
kills pre_post %reg==regvar($1, reg_pointer)
|
||||
yields {indirect4, regvar($1, reg_pointer)}
|
||||
pat lil inreg($1)==reg_any
|
||||
uses AA_REG = { LOCAL, $1}
|
||||
yields {indirect4, %a}
|
||||
|
||||
pat stl inreg($1)==reg_any
|
||||
with any4
|
||||
|
@ -754,6 +765,15 @@ with any4
|
|||
with exact STACK
|
||||
kills allexceptcon
|
||||
gen move {post_inc4, sp}, {indirect4, regvar($1, reg_pointer)}
|
||||
pat sil inreg($1)==reg_any
|
||||
with any4
|
||||
kills allexceptcon
|
||||
uses AA_REG = {LOCAL, $1}
|
||||
gen move %1, {indirect4, %a}
|
||||
with exact STACK
|
||||
kills allexceptcon
|
||||
uses AA_REG = {LOCAL, $1}
|
||||
gen move {post_inc4, sp}, {indirect4, %a}
|
||||
|
||||
|
||||
pat lol sbi stl $1==$3 && $2==4 && inreg($1)==reg_any
|
||||
|
@ -1758,12 +1778,20 @@ with any4 any4
|
|||
kills all_indir, LOCAL %bd==$1
|
||||
gen move %1, {LOCAL, $1}
|
||||
move %2, {LOCAL, $1+4}
|
||||
with exact STACK
|
||||
kills all_indir, LOCAL %bd==$1
|
||||
gen move_l {post_inc4, sp}, {LOCAL,$1}
|
||||
move_l {post_inc4, sp}, {LOCAL,$1+4}
|
||||
|
||||
pat sde
|
||||
with any4 any4
|
||||
kills posextern
|
||||
gen move %1, {absolute4, $1}
|
||||
move %2, {absolute4, $1+4}
|
||||
with exact STACK
|
||||
kills posextern
|
||||
gen move_l {post_inc4, sp}, {absolute4,$1}
|
||||
move_l {post_inc4, sp}, {absolute4,$1+4}
|
||||
|
||||
pat sdf
|
||||
with A_REG any4 any4
|
||||
|
@ -1981,20 +2009,34 @@ with D_REG DD_REG
|
|||
|
||||
/************************************************
|
||||
* Group 5: floating point arithmetic *
|
||||
* *
|
||||
* is not available on 68000, 68010 or 68020 *
|
||||
* so traps will be generated *
|
||||
************************************************/
|
||||
|
||||
pat adf leaving loc 18 trp
|
||||
pat sbf leaving loc 18 trp
|
||||
pat mlf leaving loc 18 trp
|
||||
pat dvf leaving loc 18 trp
|
||||
pat ngf leaving loc 18 trp
|
||||
pat fif leaving loc 18 trp
|
||||
pat fef leaving loc 18 trp
|
||||
|
||||
|
||||
/* Floating point stuff
|
||||
* Arithmetic instructions
|
||||
*/
|
||||
|
||||
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 cal ".fif4"
|
||||
pat fif $1==8 leaving cal ".fif8"
|
||||
pat fef $1==4 leaving dup 4 cal ".fef4"
|
||||
pat fef $1==8
|
||||
kills ALL
|
||||
gen
|
||||
move_l {post_inc4, sp}, d0
|
||||
move_l {post_inc4, sp}, d1
|
||||
move_l d0, {pre_dec4, sp}
|
||||
move_l d1, {pre_dec4, sp}
|
||||
move_l d0, {pre_dec4, sp}
|
||||
leaving cal ".fef8"
|
||||
|
||||
/************************************************
|
||||
* Group 6: pointer arithmetic *
|
||||
|
@ -2168,13 +2210,9 @@ with STACK
|
|||
dbf %a, {slabel, 1b}
|
||||
|
||||
|
||||
pat zrf leaving loc 18 trp
|
||||
|
||||
|
||||
|
||||
/************************************************
|
||||
* Group 8: convert instructions *
|
||||
* for float conversions traps are generated *
|
||||
************************************************/
|
||||
|
||||
|
||||
|
@ -2193,12 +2231,24 @@ pat ciu leaving cuu
|
|||
|
||||
pat cui leaving cuu
|
||||
|
||||
pat cfi leaving loc 18 trp
|
||||
pat cif leaving loc 18 trp
|
||||
pat cfu leaving loc 18 trp
|
||||
pat cuf leaving loc 18 trp
|
||||
pat cff leaving loc 18 trp
|
||||
|
||||
/*
|
||||
* Floating point stuff
|
||||
* Conversion
|
||||
*/
|
||||
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 4
|
||||
pat loc loc cuf $1==4 && $2==8 leaving loc 4 cal ".cuf8"
|
||||
pat loc loc cfi leaving loc $1 loc $2 cal ".cfi" asp 8+($1-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
|
||||
pat loc loc cff $1==4 && $2==8
|
||||
kills ALL
|
||||
gen
|
||||
move_l {indirect4, sp}, d0
|
||||
clr_l {indirect4, sp}
|
||||
move_l d0, {pre_dec4, sp}
|
||||
leaving cal ".cff8"
|
||||
|
||||
/************************************************
|
||||
* Group 9: logical instructions *
|
||||
|
@ -2514,9 +2564,18 @@ pat tne call txx("bne", "bne")
|
|||
pat tge call txx("bge", "bcc")
|
||||
pat tgt call txx("bgt", "bhi")
|
||||
|
||||
pat cmf leaving loc 18 trp
|
||||
|
||||
/*
|
||||
* Floating point
|
||||
* Comparision
|
||||
*/
|
||||
|
||||
pat cmf $1==4 leaving cal ".cmf4" asp 8 lfr 4
|
||||
pat cmf $1==8 leaving cal ".cmf8" asp 16 lfr 4
|
||||
/*
|
||||
* Floating Point
|
||||
* Zero Constants
|
||||
*/
|
||||
pat zrf leaving zer $1
|
||||
|
||||
/************************************************
|
||||
* Group 13: branch instructions *
|
||||
|
|
Loading…
Reference in a new issue