summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorChris Demetriou <cgd@google.com>2002-06-07 16:50:42 +0000
committerChris Demetriou <cgd@google.com>2002-06-07 16:50:42 +0000
commit5892949fd7c471ea67afaab04d14a592d017a034 (patch)
treeb6c00d16ea500f02e496c66ed987a3606d26e4f8 /sim
parentadabc33b577f9475f91d3175055aa33497462c7c (diff)
downloadgdb-5892949fd7c471ea67afaab04d14a592d017a034.tar.gz
2002-06-07 Chris Demetriou <cgd@broadcom.com>
* cp1.c (convert): Remove unusable debugging code, and move MIPS rounding mode to sim FP rounding mode flag conversion code into... (rounding_mode): New function.
Diffstat (limited to 'sim')
-rw-r--r--sim/mips/ChangeLog6
-rw-r--r--sim/mips/cp1.c76
2 files changed, 43 insertions, 39 deletions
diff --git a/sim/mips/ChangeLog b/sim/mips/ChangeLog
index 0afcde95552..8d8e30e15aa 100644
--- a/sim/mips/ChangeLog
+++ b/sim/mips/ChangeLog
@@ -1,5 +1,11 @@
2002-06-07 Chris Demetriou <cgd@broadcom.com>
+ * cp1.c (convert): Remove unusable debugging code, and move MIPS
+ rounding mode to sim FP rounding mode flag conversion code into...
+ (rounding_mode): New function.
+
+2002-06-07 Chris Demetriou <cgd@broadcom.com>
+
* cp1.c: Clean up formatting of a few comments.
(value_fpr): Reformat switch statement.
diff --git a/sim/mips/cp1.c b/sim/mips/cp1.c
index e4bfba2b028..362bcefeada 100644
--- a/sim/mips/cp1.c
+++ b/sim/mips/cp1.c
@@ -426,6 +426,42 @@ update_fcsr (sim_cpu *cpu,
return;
}
+static sim_fpu_round
+rounding_mode(int rm)
+{
+ sim_fpu_round round;
+
+ switch (rm)
+ {
+ case FP_RM_NEAREST:
+ /* Round result to nearest representable value. When two
+ representable values are equally near, round to the value
+ that has a least significant bit of zero (i.e. is even). */
+ round = sim_fpu_round_near;
+ break;
+ case FP_RM_TOZERO:
+ /* Round result to the value closest to, and not greater in
+ magnitude than, the result. */
+ round = sim_fpu_round_zero;
+ break;
+ case FP_RM_TOPINF:
+ /* Round result to the value closest to, and not less than,
+ the result. */
+ round = sim_fpu_round_up;
+ break;
+ case FP_RM_TOMINF:
+ /* Round result to the value closest to, and not greater than,
+ the result. */
+ round = sim_fpu_round_down;
+ break;
+ default:
+ round = 0;
+ fprintf (stderr, "Bad switch\n");
+ abort ();
+ }
+ return round;
+}
+
/* Comparison operations. */
@@ -694,48 +730,10 @@ convert (sim_cpu *cpu,
FP_formats to)
{
sim_fpu wop;
- sim_fpu_round round;
+ sim_fpu_round round = rounding_mode (rm);
unsigned32 result32;
unsigned64 result64;
-#ifdef DEBUG
-#if 0 /* FIXME: doesn't compile */
- printf ("DBG: Convert: mode %s : op 0x%s : from %s : to %s : (PC = 0x%s)\n",
- fpu_rounding_mode_name (rm), pr_addr (op), fpu_format_name (from),
- fpu_format_name (to), pr_addr (IPC));
-#endif
-#endif /* DEBUG */
-
- switch (rm)
- {
- case FP_RM_NEAREST:
- /* Round result to nearest representable value. When two
- representable values are equally near, round to the value
- that has a least significant bit of zero (i.e. is even). */
- round = sim_fpu_round_near;
- break;
- case FP_RM_TOZERO:
- /* Round result to the value closest to, and not greater in
- magnitude than, the result. */
- round = sim_fpu_round_zero;
- break;
- case FP_RM_TOPINF:
- /* Round result to the value closest to, and not less than,
- the result. */
- round = sim_fpu_round_up;
- break;
-
- case FP_RM_TOMINF:
- /* Round result to the value closest to, and not greater than,
- the result. */
- round = sim_fpu_round_down;
- break;
- default:
- round = 0;
- fprintf (stderr, "Bad switch\n");
- abort ();
- }
-
/* Convert the input to sim_fpu internal format */
switch (from)
{