aboutsummaryrefslogtreecommitdiff
path: root/sim/common/sim-fpu.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>1998-04-16 07:49:58 +0000
committerAndrew Cagney <cagney@redhat.com>1998-04-16 07:49:58 +0000
commit7d93d538710708a27ca1a6ae8f28ddbf47d876fa (patch)
tree3c0d5c81b519cdc5b089df07b623c3154afa43a8 /sim/common/sim-fpu.c
parent69842d0884f1fdcbe0ec1cdbcabf8439b34ea6dd (diff)
downloadgdb-7d93d538710708a27ca1a6ae8f28ddbf47d876fa.zip
gdb-7d93d538710708a27ca1a6ae8f28ddbf47d876fa.tar.gz
gdb-7d93d538710708a27ca1a6ae8f28ddbf47d876fa.tar.bz2
o CVT.S.W and CVT.W.S were reversed
o When unpacking an r5900 FP value, was not treating IEEE-NaN's as very large values. o When packing an r5900 FP result from an infinite precision intermediate value was saturating to IEEE-MAX instead of r5900-MAX o The least significant bit of the FP status register did not stick to one.
Diffstat (limited to 'sim/common/sim-fpu.c')
-rw-r--r--sim/common/sim-fpu.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/sim/common/sim-fpu.c b/sim/common/sim-fpu.c
index 99e922c..8931ad3 100644
--- a/sim/common/sim-fpu.c
+++ b/sim/common/sim-fpu.c
@@ -2,7 +2,7 @@
of the floating point routines in libgcc1.c for targets without
hardware floating point. */
-/* Copyright (C) 1994,1997 Free Software Foundation, Inc.
+/* Copyright (C) 1994,1997-1998 Free Software Foundation, Inc.
This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -712,6 +712,40 @@ sim_fpu_to64 (unsigned64 *u,
}
+INLINE_SIM_FPU (void)
+sim_fpu_fractionto (sim_fpu *f,
+ int sign,
+ int normal_exp,
+ unsigned64 fraction,
+ int precision)
+{
+ int shift = (NR_FRAC_GUARD - precision);
+ f->class = sim_fpu_class_number;
+ f->sign = sign;
+ f->normal_exp = normal_exp;
+ /* shift the fraction to where sim-fpu expects it */
+ if (shift >= 0)
+ f->fraction = (fraction << shift);
+ else
+ f->fraction = (fraction >> -shift);
+ f->fraction |= IMPLICIT_1;
+}
+
+
+INLINE_SIM_FPU (unsigned64)
+sim_fpu_tofraction (const sim_fpu *d,
+ int precision)
+{
+ /* we have NR_FRAC_GUARD bits, we want only PRECISION bits */
+ int shift = (NR_FRAC_GUARD - precision);
+ unsigned64 fraction = (d->fraction & ~IMPLICIT_1);
+ if (shift >= 0)
+ return fraction >> shift;
+ else
+ return fraction << -shift;
+}
+
+
/* Rounding */
STATIC_INLINE_SIM_FPU (int)
@@ -2186,6 +2220,7 @@ sim_fpu_exp (const sim_fpu *d)
}
+
INLINE_SIM_FPU (int)
sim_fpu_is (const sim_fpu *d)
{
@@ -2196,8 +2231,10 @@ sim_fpu_is (const sim_fpu *d)
case sim_fpu_class_snan:
return SIM_FPU_IS_SNAN;
case sim_fpu_class_infinity:
- return SIM_FPU_IS_NINF;
- return SIM_FPU_IS_PINF;
+ if (d->sign)
+ return SIM_FPU_IS_NINF;
+ else
+ return SIM_FPU_IS_PINF;
case sim_fpu_class_number:
if (d->sign)
return SIM_FPU_IS_NNUMBER;