aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Elliston <bje@au.ibm.com>2000-12-23 11:51:04 +0000
committerBen Elliston <bje@au.ibm.com>2000-12-23 11:51:04 +0000
commitb94c0966447e3864d91b17b0f71a27483a8a16a5 (patch)
tree679699739b9a88e56de792c78ec7d8826ce6c9ed
parentb21f0843bf0b6a911c96408de2edf6406a0e72ac (diff)
downloadgdb-b94c0966447e3864d91b17b0f71a27483a8a16a5.zip
gdb-b94c0966447e3864d91b17b0f71a27483a8a16a5.tar.gz
gdb-b94c0966447e3864d91b17b0f71a27483a8a16a5.tar.bz2
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 ().
-rw-r--r--sim/common/ChangeLog9
-rw-r--r--sim/common/sim-fpu.c51
-rw-r--r--sim/common/sim-fpu.h7
3 files changed, 36 insertions, 31 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 5d4fb35..c01bd90 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -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>
* cgen.sh: Set prefix/PREFIX (append ISA if applicable). Factor
diff --git a/sim/common/sim-fpu.c b/sim/common/sim-fpu.c
index 3214bb4..76391751 100644
--- a/sim/common/sim-fpu.c
+++ b/sim/common/sim-fpu.c
@@ -51,25 +51,30 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "sim-assert.h"
-/* Debugging support. */
+/* Debugging support.
+ If digits is -1, then print all digits. */
static void
print_bits (unsigned64 x,
int msbit,
+ int digits,
sim_fpu_print_func print,
void *arg)
{
unsigned64 bit = LSBIT64 (msbit);
int i = 4;
- while (bit)
+ while (bit && digits)
{
if (i == 0)
print (arg, ",");
+
if ((x & bit))
print (arg, "1");
else
print (arg, "0");
bit >>= 1;
+
+ if (digits > 0) digits--;
i = (i + 1) % 4;
}
}
@@ -1375,14 +1380,6 @@ sim_fpu_mul (sim_fpu *f,
ASSERT (high >= LSBIT64 ((NR_FRAC_GUARD * 2) - 64));
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 */
do
{
@@ -1394,13 +1391,6 @@ sim_fpu_mul (sim_fpu *f,
}
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);
if (low != 0)
{
@@ -1530,16 +1520,6 @@ sim_fpu_div (sim_fpu *f,
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 */
if ((quotient & LSMASK64 (NR_SPARE -1, 0)))
quotient = (quotient >> NR_SPARE) | 1;
@@ -2477,17 +2457,26 @@ sim_fpu_print_fpu (const sim_fpu *f,
sim_fpu_print_func *print,
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 ? "-" : "+");
switch (f->class)
{
case sim_fpu_class_qnan:
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");
break;
case sim_fpu_class_snan:
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");
break;
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_denorm:
print (arg, "1.");
- print_bits (f->fraction, NR_FRAC_GUARD - 1, print, arg);
- print (arg, "*2^%+-5d", f->normal_exp);
+ print_bits (f->fraction, NR_FRAC_GUARD - 1, digits, print, arg);
+ print (arg, "*2^%+d", f->normal_exp);
ASSERT (f->fraction >= IMPLICIT_1);
ASSERT (f->fraction < IMPLICIT_2);
}
diff --git a/sim/common/sim-fpu.h b/sim/common/sim-fpu.h
index 1f40676..91adad8 100644
--- a/sim/common/sim-fpu.h
+++ b/sim/common/sim-fpu.h
@@ -402,10 +402,17 @@ extern const sim_fpu sim_fpu_max64;
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,
sim_fpu_print_func *print,
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,
sim_fpu_print_func *print,
void *arg);