2000-12-15 Ben Elliston <bje@redhat.com>
* sim-fpu.h (sim_fpu_printn_fpu): Declare. * sim-fpu.c (print_bits): Add digits parameter. Print only as many trailing digits as specified (-1 to print all digits). (sim_fpu_print_fpu): New wrapper around sim_fpu_printn_fpu. (sim_fpu_printn_fpu): Rename from sim_fpu_print_fpu; update calls to print_bits ().
This commit is contained in:
parent
b21f0843bf
commit
b94c096644
3 changed files with 36 additions and 31 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2000-12-15 Ben Elliston <bje@redhat.com>
|
||||||
|
|
||||||
|
* sim-fpu.h (sim_fpu_printn_fpu): Declare.
|
||||||
|
* sim-fpu.c (print_bits): Add digits parameter. Print only as many
|
||||||
|
trailing digits as specified (-1 to print all digits).
|
||||||
|
(sim_fpu_print_fpu): New wrapper around sim_fpu_printn_fpu.
|
||||||
|
(sim_fpu_printn_fpu): Rename from sim_fpu_print_fpu; update calls
|
||||||
|
to print_bits ().
|
||||||
|
|
||||||
2000-12-13 Ben Elliston <bje@redhat.com>
|
2000-12-13 Ben Elliston <bje@redhat.com>
|
||||||
|
|
||||||
* cgen.sh: Set prefix/PREFIX (append ISA if applicable). Factor
|
* cgen.sh: Set prefix/PREFIX (append ISA if applicable). Factor
|
||||||
|
|
|
@ -51,25 +51,30 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
#include "sim-assert.h"
|
#include "sim-assert.h"
|
||||||
|
|
||||||
|
|
||||||
/* Debugging support. */
|
/* Debugging support.
|
||||||
|
If digits is -1, then print all digits. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_bits (unsigned64 x,
|
print_bits (unsigned64 x,
|
||||||
int msbit,
|
int msbit,
|
||||||
|
int digits,
|
||||||
sim_fpu_print_func print,
|
sim_fpu_print_func print,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
unsigned64 bit = LSBIT64 (msbit);
|
unsigned64 bit = LSBIT64 (msbit);
|
||||||
int i = 4;
|
int i = 4;
|
||||||
while (bit)
|
while (bit && digits)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
print (arg, ",");
|
print (arg, ",");
|
||||||
|
|
||||||
if ((x & bit))
|
if ((x & bit))
|
||||||
print (arg, "1");
|
print (arg, "1");
|
||||||
else
|
else
|
||||||
print (arg, "0");
|
print (arg, "0");
|
||||||
bit >>= 1;
|
bit >>= 1;
|
||||||
|
|
||||||
|
if (digits > 0) digits--;
|
||||||
i = (i + 1) % 4;
|
i = (i + 1) % 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1375,14 +1380,6 @@ sim_fpu_mul (sim_fpu *f,
|
||||||
ASSERT (high >= LSBIT64 ((NR_FRAC_GUARD * 2) - 64));
|
ASSERT (high >= LSBIT64 ((NR_FRAC_GUARD * 2) - 64));
|
||||||
ASSERT (LSBIT64 (((NR_FRAC_GUARD + 1) * 2) - 64) < IMPLICIT_1);
|
ASSERT (LSBIT64 (((NR_FRAC_GUARD + 1) * 2) - 64) < IMPLICIT_1);
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf ("\n");
|
|
||||||
print_bits (high, 63, (sim_fpu_print_func*)fprintf, stdout);
|
|
||||||
printf (";");
|
|
||||||
print_bits (low, 63, (sim_fpu_print_func*)fprintf, stdout);
|
|
||||||
printf ("\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* normalize */
|
/* normalize */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -1394,13 +1391,6 @@ sim_fpu_mul (sim_fpu *f,
|
||||||
}
|
}
|
||||||
while (high < IMPLICIT_1);
|
while (high < IMPLICIT_1);
|
||||||
|
|
||||||
#if 0
|
|
||||||
print_bits (high, 63, (sim_fpu_print_func*)fprintf, stdout);
|
|
||||||
printf (";");
|
|
||||||
print_bits (low, 63, (sim_fpu_print_func*)fprintf, stdout);
|
|
||||||
printf ("\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ASSERT (high >= IMPLICIT_1 && high < IMPLICIT_2);
|
ASSERT (high >= IMPLICIT_1 && high < IMPLICIT_2);
|
||||||
if (low != 0)
|
if (low != 0)
|
||||||
{
|
{
|
||||||
|
@ -1530,16 +1520,6 @@ sim_fpu_div (sim_fpu *f,
|
||||||
numerator <<= 1;
|
numerator <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
printf ("\n");
|
|
||||||
print_bits (quotient, 63, (sim_fpu_print_func*)fprintf, stdout);
|
|
||||||
printf ("\n");
|
|
||||||
print_bits (numerator, 63, (sim_fpu_print_func*)fprintf, stdout);
|
|
||||||
printf ("\n");
|
|
||||||
print_bits (denominator, 63, (sim_fpu_print_func*)fprintf, stdout);
|
|
||||||
printf ("\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* discard (but save) the extra bits */
|
/* discard (but save) the extra bits */
|
||||||
if ((quotient & LSMASK64 (NR_SPARE -1, 0)))
|
if ((quotient & LSMASK64 (NR_SPARE -1, 0)))
|
||||||
quotient = (quotient >> NR_SPARE) | 1;
|
quotient = (quotient >> NR_SPARE) | 1;
|
||||||
|
@ -2476,18 +2456,27 @@ INLINE_SIM_FPU (void)
|
||||||
sim_fpu_print_fpu (const sim_fpu *f,
|
sim_fpu_print_fpu (const sim_fpu *f,
|
||||||
sim_fpu_print_func *print,
|
sim_fpu_print_func *print,
|
||||||
void *arg)
|
void *arg)
|
||||||
|
{
|
||||||
|
sim_fpu_printn_fpu (f, print, -1, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE_SIM_FPU (void)
|
||||||
|
sim_fpu_printn_fpu (const sim_fpu *f,
|
||||||
|
sim_fpu_print_func *print,
|
||||||
|
int digits,
|
||||||
|
void *arg)
|
||||||
{
|
{
|
||||||
print (arg, "%s", f->sign ? "-" : "+");
|
print (arg, "%s", f->sign ? "-" : "+");
|
||||||
switch (f->class)
|
switch (f->class)
|
||||||
{
|
{
|
||||||
case sim_fpu_class_qnan:
|
case sim_fpu_class_qnan:
|
||||||
print (arg, "0.");
|
print (arg, "0.");
|
||||||
print_bits (f->fraction, NR_FRAC_GUARD - 1, print, arg);
|
print_bits (f->fraction, NR_FRAC_GUARD - 1, digits, print, arg);
|
||||||
print (arg, "*QuietNaN");
|
print (arg, "*QuietNaN");
|
||||||
break;
|
break;
|
||||||
case sim_fpu_class_snan:
|
case sim_fpu_class_snan:
|
||||||
print (arg, "0.");
|
print (arg, "0.");
|
||||||
print_bits (f->fraction, NR_FRAC_GUARD - 1, print, arg);
|
print_bits (f->fraction, NR_FRAC_GUARD - 1, digits, print, arg);
|
||||||
print (arg, "*SignalNaN");
|
print (arg, "*SignalNaN");
|
||||||
break;
|
break;
|
||||||
case sim_fpu_class_zero:
|
case sim_fpu_class_zero:
|
||||||
|
@ -2499,8 +2488,8 @@ sim_fpu_print_fpu (const sim_fpu *f,
|
||||||
case sim_fpu_class_number:
|
case sim_fpu_class_number:
|
||||||
case sim_fpu_class_denorm:
|
case sim_fpu_class_denorm:
|
||||||
print (arg, "1.");
|
print (arg, "1.");
|
||||||
print_bits (f->fraction, NR_FRAC_GUARD - 1, print, arg);
|
print_bits (f->fraction, NR_FRAC_GUARD - 1, digits, print, arg);
|
||||||
print (arg, "*2^%+-5d", f->normal_exp);
|
print (arg, "*2^%+d", f->normal_exp);
|
||||||
ASSERT (f->fraction >= IMPLICIT_1);
|
ASSERT (f->fraction >= IMPLICIT_1);
|
||||||
ASSERT (f->fraction < IMPLICIT_2);
|
ASSERT (f->fraction < IMPLICIT_2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,10 +402,17 @@ extern const sim_fpu sim_fpu_max64;
|
||||||
|
|
||||||
typedef void sim_fpu_print_func (void *, char *, ...);
|
typedef void sim_fpu_print_func (void *, char *, ...);
|
||||||
|
|
||||||
|
/* Print a sim_fpu with full precision. */
|
||||||
INLINE_SIM_FPU (void) sim_fpu_print_fpu (const sim_fpu *f,
|
INLINE_SIM_FPU (void) sim_fpu_print_fpu (const sim_fpu *f,
|
||||||
sim_fpu_print_func *print,
|
sim_fpu_print_func *print,
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
||||||
|
/* Print a sim_fpu with `n' trailing digits. */
|
||||||
|
INLINE_SIM_FPU (void) sim_fpu_printn_fpu (const sim_fpu *f,
|
||||||
|
sim_fpu_print_func *print,
|
||||||
|
int digits,
|
||||||
|
void *arg);
|
||||||
|
|
||||||
INLINE_SIM_FPU (void) sim_fpu_print_status (int status,
|
INLINE_SIM_FPU (void) sim_fpu_print_status (int status,
|
||||||
sim_fpu_print_func *print,
|
sim_fpu_print_func *print,
|
||||||
void *arg);
|
void *arg);
|
||||||
|
|
Loading…
Add table
Reference in a new issue