* rs6000-tdep.c (set_sim_regno, init_sim_regno_table,
[deliverable/binutils-gdb.git] / gdb / mips-tdep.c
index b1a277854ebe669eef0d783985df9c7ced4581e5..e02202cc93750c769305a83d196208c98cdbd0bb 100644 (file)
@@ -54,6 +54,7 @@
 #include "frame-base.h"
 #include "trad-frame.h"
 #include "infcall.h"
+#include "floatformat.h"
 
 static const struct objfile_data *mips_pdr_data;
 
@@ -149,6 +150,32 @@ struct gdbarch_tdep
   const char **mips_processor_reg_names;
 };
 
+static int
+n32n64_floatformat_always_valid (const struct floatformat *fmt,
+                                 const char *from)
+{
+  return 1;
+}
+
+/* FIXME: brobecker/2004-08-08: Long Double values are 128 bit long.
+   They are implemented as a pair of 64bit doubles where the high
+   part holds the result of the operation rounded to double, and
+   the low double holds the difference between the exact result and
+   the rounded result.  So "high" + "low" contains the result with
+   added precision.  Unfortunately, the floatformat structure used
+   by GDB is not powerful enough to describe this format.  As a temporary
+   measure, we define a 128bit floatformat that only uses the high part.
+   We lose a bit of precision but that's probably the best we can do
+   for now with the current infrastructure.  */
+
+static const struct floatformat floatformat_n32n64_long_double_big =
+{
+  floatformat_big, 128, 0, 1, 11, 1023, 2047, 12, 52,
+  floatformat_intbit_no,
+  "floatformat_ieee_double_big",
+  n32n64_floatformat_always_valid
+};
+
 const struct mips_regnum *
 mips_regnum (struct gdbarch *gdbarch)
 {
@@ -1778,8 +1805,12 @@ mips_mdebug_frame_base_sniffer (struct frame_info *next_frame)
     return NULL;
 }
 
+/* Heuristic unwinder for 16-bit MIPS instruction set (aka MIPS16).
+   Procedures that use the 32-bit instruction set are handled by the
+   mips_insn32 unwinder.  */
+
 static struct mips_frame_cache *
-mips16_frame_cache (struct frame_info *next_frame, void **this_cache)
+mips_insn16_frame_cache (struct frame_info *next_frame, void **this_cache)
 {
   mips_extra_func_info_t proc_desc;
   struct mips_frame_cache *cache;
@@ -1963,71 +1994,76 @@ mips16_frame_cache (struct frame_info *next_frame, void **this_cache)
 }
 
 static void
-mips16_frame_this_id (struct frame_info *next_frame, void **this_cache,
+mips_insn16_frame_this_id (struct frame_info *next_frame, void **this_cache,
                           struct frame_id *this_id)
 {
-  struct mips_frame_cache *info = mips16_frame_cache (next_frame,
+  struct mips_frame_cache *info = mips_insn16_frame_cache (next_frame,
                                                           this_cache);
   (*this_id) = frame_id_build (info->base, frame_func_unwind (next_frame));
 }
 
 static void
-mips16_frame_prev_register (struct frame_info *next_frame,
+mips_insn16_frame_prev_register (struct frame_info *next_frame,
                                 void **this_cache,
                                 int regnum, int *optimizedp,
                                 enum lval_type *lvalp, CORE_ADDR *addrp,
                                 int *realnump, void *valuep)
 {
-  struct mips_frame_cache *info = mips16_frame_cache (next_frame,
+  struct mips_frame_cache *info = mips_insn16_frame_cache (next_frame,
                                                           this_cache);
   trad_frame_get_prev_register (next_frame, info->saved_regs, regnum,
                                optimizedp, lvalp, addrp, realnump, valuep);
 }
 
-static const struct frame_unwind mips16_frame_unwind =
+static const struct frame_unwind mips_insn16_frame_unwind =
 {
   NORMAL_FRAME,
-  mips16_frame_this_id,
-  mips16_frame_prev_register
+  mips_insn16_frame_this_id,
+  mips_insn16_frame_prev_register
 };
 
 static const struct frame_unwind *
-mips16_frame_sniffer (struct frame_info *next_frame)
+mips_insn16_frame_sniffer (struct frame_info *next_frame)
 {
   CORE_ADDR pc = frame_pc_unwind (next_frame);
   if (pc_is_mips16 (pc))
-    return &mips16_frame_unwind;
+    return &mips_insn16_frame_unwind;
   return NULL;
 }
 
 static CORE_ADDR
-mips16_frame_base_address (struct frame_info *next_frame,
+mips_insn16_frame_base_address (struct frame_info *next_frame,
                                void **this_cache)
 {
-  struct mips_frame_cache *info = mips16_frame_cache (next_frame,
+  struct mips_frame_cache *info = mips_insn16_frame_cache (next_frame,
                                                           this_cache);
   return info->base;
 }
 
-static const struct frame_base mips16_frame_base =
+static const struct frame_base mips_insn16_frame_base =
 {
-  &mips16_frame_unwind,
-  mips16_frame_base_address,
-  mips16_frame_base_address,
-  mips16_frame_base_address
+  &mips_insn16_frame_unwind,
+  mips_insn16_frame_base_address,
+  mips_insn16_frame_base_address,
+  mips_insn16_frame_base_address
 };
 
 static const struct frame_base *
-mips16_frame_base_sniffer (struct frame_info *next_frame)
+mips_insn16_frame_base_sniffer (struct frame_info *next_frame)
 {
-  if (mips16_frame_sniffer (next_frame) != NULL)
-    return &mips16_frame_base;
+  if (mips_insn16_frame_sniffer (next_frame) != NULL)
+    return &mips_insn16_frame_base;
   else
     return NULL;
 }
 
+/* Heuristic unwinder for procedures using 32-bit instructions (covers
+   both 32-bit and 64-bit MIPS ISAs).  Procedures using 16-bit
+   instructions (a.k.a. MIPS16) are handled by the mips_insn16
+   unwinder.  */
+
 static struct mips_frame_cache *
-mips32_frame_cache (struct frame_info *next_frame, void **this_cache)
+mips_insn32_frame_cache (struct frame_info *next_frame, void **this_cache)
 {
   mips_extra_func_info_t proc_desc;
   struct mips_frame_cache *cache;
@@ -2211,65 +2247,65 @@ mips32_frame_cache (struct frame_info *next_frame, void **this_cache)
 }
 
 static void
-mips32_frame_this_id (struct frame_info *next_frame, void **this_cache,
+mips_insn32_frame_this_id (struct frame_info *next_frame, void **this_cache,
                           struct frame_id *this_id)
 {
-  struct mips_frame_cache *info = mips32_frame_cache (next_frame,
+  struct mips_frame_cache *info = mips_insn32_frame_cache (next_frame,
                                                           this_cache);
   (*this_id) = frame_id_build (info->base, frame_func_unwind (next_frame));
 }
 
 static void
-mips32_frame_prev_register (struct frame_info *next_frame,
+mips_insn32_frame_prev_register (struct frame_info *next_frame,
                                 void **this_cache,
                                 int regnum, int *optimizedp,
                                 enum lval_type *lvalp, CORE_ADDR *addrp,
                                 int *realnump, void *valuep)
 {
-  struct mips_frame_cache *info = mips32_frame_cache (next_frame,
+  struct mips_frame_cache *info = mips_insn32_frame_cache (next_frame,
                                                           this_cache);
   trad_frame_get_prev_register (next_frame, info->saved_regs, regnum,
                                optimizedp, lvalp, addrp, realnump, valuep);
 }
 
-static const struct frame_unwind mips32_frame_unwind =
+static const struct frame_unwind mips_insn32_frame_unwind =
 {
   NORMAL_FRAME,
-  mips32_frame_this_id,
-  mips32_frame_prev_register
+  mips_insn32_frame_this_id,
+  mips_insn32_frame_prev_register
 };
 
 static const struct frame_unwind *
-mips32_frame_sniffer (struct frame_info *next_frame)
+mips_insn32_frame_sniffer (struct frame_info *next_frame)
 {
   CORE_ADDR pc = frame_pc_unwind (next_frame);
   if (! pc_is_mips16 (pc))
-    return &mips32_frame_unwind;
+    return &mips_insn32_frame_unwind;
   return NULL;
 }
 
 static CORE_ADDR
-mips32_frame_base_address (struct frame_info *next_frame,
+mips_insn32_frame_base_address (struct frame_info *next_frame,
                                void **this_cache)
 {
-  struct mips_frame_cache *info = mips32_frame_cache (next_frame,
+  struct mips_frame_cache *info = mips_insn32_frame_cache (next_frame,
                                                           this_cache);
   return info->base;
 }
 
-static const struct frame_base mips32_frame_base =
+static const struct frame_base mips_insn32_frame_base =
 {
-  &mips32_frame_unwind,
-  mips32_frame_base_address,
-  mips32_frame_base_address,
-  mips32_frame_base_address
+  &mips_insn32_frame_unwind,
+  mips_insn32_frame_base_address,
+  mips_insn32_frame_base_address,
+  mips_insn32_frame_base_address
 };
 
 static const struct frame_base *
-mips32_frame_base_sniffer (struct frame_info *next_frame)
+mips_insn32_frame_base_sniffer (struct frame_info *next_frame)
 {
-  if (mips32_frame_sniffer (next_frame) != NULL)
-    return &mips32_frame_base;
+  if (mips_insn32_frame_sniffer (next_frame) != NULL)
+    return &mips_insn32_frame_base;
   else
     return NULL;
 }
@@ -6314,6 +6350,9 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_gdbarch_long_bit (gdbarch, 32);
       set_gdbarch_ptr_bit (gdbarch, 32);
       set_gdbarch_long_long_bit (gdbarch, 64);
+      set_gdbarch_long_double_bit (gdbarch, 128);
+      set_gdbarch_long_double_format (gdbarch,
+                                      &floatformat_n32n64_long_double_big);
       break;
     case MIPS_ABI_N64:
       set_gdbarch_push_dummy_call (gdbarch, mips_n32n64_push_dummy_call);
@@ -6324,6 +6363,9 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       set_gdbarch_long_bit (gdbarch, 64);
       set_gdbarch_ptr_bit (gdbarch, 64);
       set_gdbarch_long_long_bit (gdbarch, 64);
+      set_gdbarch_long_double_bit (gdbarch, 128);
+      set_gdbarch_long_double_format (gdbarch,
+                                      &floatformat_n32n64_long_double_big);
       break;
     default:
       internal_error (__FILE__, __LINE__, "unknown ABI in switch");
@@ -6427,12 +6469,12 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Unwind the frame.  */
   frame_unwind_append_sniffer (gdbarch, mips_stub_frame_sniffer);
   frame_unwind_append_sniffer (gdbarch, mips_mdebug_frame_sniffer);
-  frame_unwind_append_sniffer (gdbarch, mips16_frame_sniffer);
-  frame_unwind_append_sniffer (gdbarch, mips32_frame_sniffer);
+  frame_unwind_append_sniffer (gdbarch, mips_insn16_frame_sniffer);
+  frame_unwind_append_sniffer (gdbarch, mips_insn32_frame_sniffer);
   frame_base_append_sniffer (gdbarch, mips_stub_frame_base_sniffer);
   frame_base_append_sniffer (gdbarch, mips_mdebug_frame_base_sniffer);
-  frame_base_append_sniffer (gdbarch, mips16_frame_base_sniffer);
-  frame_base_append_sniffer (gdbarch, mips32_frame_base_sniffer);
+  frame_base_append_sniffer (gdbarch, mips_insn16_frame_base_sniffer);
+  frame_base_append_sniffer (gdbarch, mips_insn32_frame_base_sniffer);
 
   return gdbarch;
 }
This page took 0.027591 seconds and 4 git commands to generate.