From: ceriel Date: Mon, 31 Jul 1989 14:25:53 +0000 (+0000) Subject: use con_float file, and use new interface to fif and fef routines X-Git-Tag: release-5-5~2315 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=0ef99949bca006f214033489d3777bc2f042d374;p=ack.git use con_float file, and use new interface to fif and fef routines --- diff --git a/mach/i86/ncg/mach.c b/mach/i86/ncg/mach.c index 009f84d7c..7ac6d1f44 100644 --- a/mach/i86/ncg/mach.c +++ b/mach/i86/ncg/mach.c @@ -41,149 +41,9 @@ con_mult(sz) word sz; { (int)l&0xFFFF,(int)(l>>16)&0xFFFF); } -#ifdef NOFLOAT -con_float() { - -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 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 CODE_GENERATOR +#define IEEEFLOAT +#include /* diff --git a/mach/i86/ncg/table b/mach/i86/ncg/table index ce080e8fd..5d00366a6 100644 --- a/mach/i86/ncg/table +++ b/mach/i86/ncg/table @@ -1119,22 +1119,10 @@ 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 -with REG REG - kills ALL - gen push %2 - push %2 - push %1 leaving cal ".fef4" -pat fef $1==8 -with REG REG REG REG - kills ALL - gen push %4 - push %4 - push %3 - push %2 - push %1 leaving cal ".fef8" +pat fif $1==4 leaving lor 1 cal ".fif4" asp 2 +pat fif $1==8 leaving lor 1 cal ".fif8" asp 2 +pat fef $1==4 leaving lor 1 adp 0-2 cal ".fef4" +pat fef $1==8 leaving lor 1 adp 0-2 cal ".fef8" /****************************************************************** * Group 6: Pointer Arithmetic *