* mips-tdep.c (fetch_mips_16): Fix typos and reformat the
[binutils-gdb.git] / gdb / mips-tdep.c
index 89e91c0f045acbb4866220ce7754ad287c29d21b..751945e54e887a1d98d36044793b3576da0c1682 100644 (file)
@@ -266,36 +266,6 @@ unmake_mips16_addr (CORE_ADDR addr)
   return ((addr) & ~(CORE_ADDR) 1);
 }
 
-/* Return the contents of register REGNUM as a signed integer.  */
-
-static LONGEST
-read_signed_register (int regnum)
-{
-  LONGEST val;
-  regcache_cooked_read_signed (current_regcache, regnum, &val);
-  return val;
-}
-
-static LONGEST
-read_signed_register_pid (int regnum, ptid_t ptid)
-{
-  ptid_t save_ptid;
-  LONGEST retval;
-
-  if (ptid_equal (ptid, inferior_ptid))
-    return read_signed_register (regnum);
-
-  save_ptid = inferior_ptid;
-
-  inferior_ptid = ptid;
-
-  retval = read_signed_register (regnum);
-
-  inferior_ptid = save_ptid;
-
-  return retval;
-}
-
 /* Return the MIPS ABI associated with GDBARCH.  */
 enum mips_abi
 mips_abi (struct gdbarch *gdbarch)
@@ -427,7 +397,7 @@ mips_xfer_register (struct regcache *regcache, int reg_num, int length,
    physical 64-bit registers, but should treat them as 32-bit registers.  */
 
 static int
-mips2_fp_compat (void)
+mips2_fp_compat (struct frame_info *frame)
 {
   /* MIPS1 and MIPS2 have only 32 bit FPRs, and the FR bit is not
      meaningful.  */
@@ -441,7 +411,7 @@ mips2_fp_compat (void)
   /* Otherwise check the FR bit in the status register - it controls
      the FP compatiblity mode.  If it is clear we are in compatibility
      mode.  */
-  if ((read_register (MIPS_PS_REGNUM) & ST0_FR) == 0)
+  if ((get_frame_register_unsigned (frame, MIPS_PS_REGNUM) & ST0_FR) == 0)
     return 1;
 #endif
 
@@ -452,8 +422,6 @@ mips2_fp_compat (void)
 
 static CORE_ADDR heuristic_proc_start (CORE_ADDR);
 
-static CORE_ADDR read_next_frame_reg (struct frame_info *, int);
-
 static void reinit_frame_cache_sfunc (char *, int, struct cmd_list_element *);
 
 static struct type *mips_float_register_type (void);
@@ -928,9 +896,12 @@ mips_pc_is_mips16 (CORE_ADDR memaddr)
    all registers should be sign extended for simplicity? */
 
 static CORE_ADDR
-mips_read_pc (ptid_t ptid)
+mips_read_pc (struct regcache *regcache)
 {
-  return read_signed_register_pid (mips_regnum (current_gdbarch)->pc, ptid);
+  ULONGEST pc;
+  int regnum = mips_regnum (get_regcache_arch (regcache))->pc;
+  regcache_cooked_read_signed (regcache, regnum, &pc);
+  return pc;
 }
 
 static CORE_ADDR
@@ -965,9 +936,10 @@ mips_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
 }
 
 static void
-mips_write_pc (CORE_ADDR pc, ptid_t ptid)
+mips_write_pc (struct regcache *regcache, CORE_ADDR pc)
 {
-  write_register_pid (mips_regnum (current_gdbarch)->pc, pc, ptid);
+  int regnum = mips_regnum (get_regcache_arch (regcache))->pc;
+  regcache_cooked_write_unsigned (regcache, regnum, pc);
 }
 
 /* Fetch and return instruction from the specified location.  If the PC
@@ -1019,7 +991,7 @@ mips32_relative_offset (ULONGEST inst)
 /* Determine where to set a single step breakpoint while considering
    branch prediction.  */
 static CORE_ADDR
-mips32_next_pc (CORE_ADDR pc)
+mips32_next_pc (struct frame_info *frame, CORE_ADDR pc)
 {
   unsigned long inst;
   int op;
@@ -1050,8 +1022,8 @@ mips32_next_pc (CORE_ADDR pc)
          int tf = itype_rt (inst) & 0x01;
          int cnum = itype_rt (inst) >> 2;
          int fcrcs =
-           read_signed_register (mips_regnum (current_gdbarch)->
-                                 fp_control_status);
+           get_frame_register_signed (frame, mips_regnum (current_gdbarch)->
+                                               fp_control_status);
          int cond = ((fcrcs >> 24) & 0x0e) | ((fcrcs >> 23) & 0x01);
 
          if (((cond >> cnum) & 0x01) == tf)
@@ -1075,7 +1047,7 @@ mips32_next_pc (CORE_ADDR pc)
            case 8:             /* JR */
            case 9:             /* JALR */
              /* Set PC to that address */
-             pc = read_signed_register (rtype_rs (inst));
+             pc = get_frame_register_signed (frame, rtype_rs (inst));
              break;
            default:
              pc += 4;
@@ -1092,7 +1064,7 @@ mips32_next_pc (CORE_ADDR pc)
              case 16:          /* BLTZAL */
              case 18:          /* BLTZALL */
              less_branch:
-               if (read_signed_register (itype_rs (inst)) < 0)
+               if (get_frame_register_signed (frame, itype_rs (inst)) < 0)
                  pc += mips32_relative_offset (inst) + 4;
                else
                  pc += 8;      /* after the delay slot */
@@ -1101,7 +1073,7 @@ mips32_next_pc (CORE_ADDR pc)
              case 3:           /* BGEZL */
              case 17:          /* BGEZAL */
              case 19:          /* BGEZALL */
-               if (read_signed_register (itype_rs (inst)) >= 0)
+               if (get_frame_register_signed (frame, itype_rs (inst)) >= 0)
                  pc += mips32_relative_offset (inst) + 4;
                else
                  pc += 8;      /* after the delay slot */
@@ -1131,22 +1103,22 @@ mips32_next_pc (CORE_ADDR pc)
          break;                /* The new PC will be alternate mode */
        case 4:         /* BEQ, BEQL */
        equal_branch:
-         if (read_signed_register (itype_rs (inst)) ==
-             read_signed_register (itype_rt (inst)))
+         if (get_frame_register_signed (frame, itype_rs (inst)) ==
+             get_frame_register_signed (frame, itype_rt (inst)))
            pc += mips32_relative_offset (inst) + 4;
          else
            pc += 8;
          break;
        case 5:         /* BNE, BNEL */
        neq_branch:
-         if (read_signed_register (itype_rs (inst)) !=
-             read_signed_register (itype_rt (inst)))
+         if (get_frame_register_signed (frame, itype_rs (inst)) !=
+             get_frame_register_signed (frame, itype_rt (inst)))
            pc += mips32_relative_offset (inst) + 4;
          else
            pc += 8;
          break;
        case 6:         /* BLEZ, BLEZL */
-         if (read_signed_register (itype_rs (inst)) <= 0)
+         if (get_frame_register_signed (frame, itype_rs (inst)) <= 0)
            pc += mips32_relative_offset (inst) + 4;
          else
            pc += 8;
@@ -1154,7 +1126,7 @@ mips32_next_pc (CORE_ADDR pc)
        case 7:
        default:
        greater_branch: /* BGTZ, BGTZL */
-         if (read_signed_register (itype_rs (inst)) > 0)
+         if (get_frame_register_signed (frame, itype_rs (inst)) > 0)
            pc += mips32_relative_offset (inst) + 4;
          else
            pc += 8;
@@ -1226,13 +1198,11 @@ extended_offset (unsigned int extension)
 }
 
 /* Only call this function if you know that this is an extendable
-   instruction, It wont malfunction, but why make excess remote memory references?
-   If the immediate operands get sign extended or somthing, do it after
-   the extension is performed.
- */
+   instruction.  It won't malfunction, but why make excess remote memory
+   references?  If the immediate operands get sign extended or something,
+   do it after the extension is performed.  */
 /* FIXME: Every one of these cases needs to worry about sign extension
-   when the offset is to be used in relative addressing */
-
+   when the offset is to be used in relative addressing.  */
 
 static unsigned int
 fetch_mips_16 (CORE_ADDR pc)
@@ -1335,7 +1305,7 @@ add_offset_16 (CORE_ADDR pc, int offset)
 }
 
 static CORE_ADDR
-extended_mips16_next_pc (CORE_ADDR pc,
+extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
                         unsigned int extension, unsigned int insn)
 {
   int op = (insn >> 11);
@@ -1371,7 +1341,7 @@ extended_mips16_next_pc (CORE_ADDR pc,
        struct upk_mips16 upk;
        int reg;
        unpack_mips16 (pc, extension, insn, ritype, &upk);
-       reg = read_signed_register (upk.regx);
+       reg = get_frame_register_signed (frame, upk.regx);
        if (reg == 0)
          pc += (upk.offset << 1) + 2;
        else
@@ -1383,7 +1353,7 @@ extended_mips16_next_pc (CORE_ADDR pc,
        struct upk_mips16 upk;
        int reg;
        unpack_mips16 (pc, extension, insn, ritype, &upk);
-       reg = read_signed_register (upk.regx);
+       reg = get_frame_register_signed (frame, upk.regx);
        if (reg != 0)
          pc += (upk.offset << 1) + 2;
        else
@@ -1396,7 +1366,7 @@ extended_mips16_next_pc (CORE_ADDR pc,
        int reg;
        unpack_mips16 (pc, extension, insn, i8type, &upk);
        /* upk.regx contains the opcode */
-       reg = read_signed_register (24);        /* Test register is 24 */
+       reg = get_frame_register_signed (frame, 24);  /* Test register is 24 */
        if (((upk.regx == 0) && (reg == 0))     /* BTEZ */
            || ((upk.regx == 1) && (reg != 0))) /* BTNEZ */
          /* pc = add_offset_16(pc,upk.offset) ; */
@@ -1430,7 +1400,7 @@ extended_mips16_next_pc (CORE_ADDR pc,
                reg = 31;
                break;          /* BOGUS Guess */
              }
-           pc = read_signed_register (reg);
+           pc = get_frame_register_signed (frame, reg);
          }
        else
          pc += 2;
@@ -1442,7 +1412,7 @@ extended_mips16_next_pc (CORE_ADDR pc,
          that. */
       {
        pc += 2;
-       pc = extended_mips16_next_pc (pc, insn, fetch_mips_16 (pc));
+       pc = extended_mips16_next_pc (frame, pc, insn, fetch_mips_16 (pc));
        break;
       }
     default:
@@ -1455,10 +1425,10 @@ extended_mips16_next_pc (CORE_ADDR pc,
 }
 
 static CORE_ADDR
-mips16_next_pc (CORE_ADDR pc)
+mips16_next_pc (struct frame_info *frame, CORE_ADDR pc)
 {
   unsigned int insn = fetch_mips_16 (pc);
-  return extended_mips16_next_pc (pc, 0, insn);
+  return extended_mips16_next_pc (frame, pc, 0, insn);
 }
 
 /* The mips_next_pc function supports single_step when the remote
@@ -1467,12 +1437,12 @@ mips16_next_pc (CORE_ADDR pc)
    branch will go. This isnt hard because all the data is available.
    The MIPS32 and MIPS16 variants are quite different */
 static CORE_ADDR
-mips_next_pc (CORE_ADDR pc)
+mips_next_pc (struct frame_info *frame, CORE_ADDR pc)
 {
   if (pc & 0x01)
-    return mips16_next_pc (pc);
+    return mips16_next_pc (frame, pc);
   else
-    return mips32_next_pc (pc);
+    return mips32_next_pc (frame, pc);
 }
 
 struct mips_frame_cache
@@ -1571,8 +1541,9 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
   /* Can be called when there's no process, and hence when there's no
      NEXT_FRAME.  */
   if (next_frame != NULL)
-    sp = read_next_frame_reg (next_frame, gdbarch_num_regs (current_gdbarch)
-                                          + MIPS_SP_REGNUM);
+    sp = frame_unwind_register_signed (next_frame,
+                                      gdbarch_num_regs (current_gdbarch)
+                                      + MIPS_SP_REGNUM);
   else
     sp = 0;
 
@@ -1778,7 +1749,7 @@ mips_insn16_frame_cache (struct frame_info *next_frame, void **this_cache)
     mips16_scan_prologue (start_addr, pc, next_frame, *this_cache);
   }
   
-  /* SP_REGNUM, contains the value and not the address.  */
+  /* gdbarch_sp_regnum contains the value and not the address.  */
   trad_frame_set_value (cache->saved_regs, gdbarch_num_regs (current_gdbarch)
                                           + MIPS_SP_REGNUM, cache->base);
 
@@ -1892,8 +1863,9 @@ mips32_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
   /* Can be called when there's no process, and hence when there's no
      NEXT_FRAME.  */
   if (next_frame != NULL)
-    sp = read_next_frame_reg (next_frame, gdbarch_num_regs (current_gdbarch)
-                                         + MIPS_SP_REGNUM);
+    sp = frame_unwind_register_signed (next_frame,
+                                      gdbarch_num_regs (current_gdbarch)
+                                      + MIPS_SP_REGNUM);
   else
     sp = 0;
 
@@ -1943,14 +1915,15 @@ restart:
          /* Old gcc frame, r30 is virtual frame pointer.  */
          if ((long) low_word != frame_offset)
            frame_addr = sp + low_word;
-         else if (frame_reg == MIPS_SP_REGNUM)
+         else if (next_frame && frame_reg == MIPS_SP_REGNUM)
            {
              unsigned alloca_adjust;
 
              frame_reg = 30;
-             frame_addr = read_next_frame_reg (next_frame,
-                                               gdbarch_num_regs
-                                                 (current_gdbarch) + 30);
+             frame_addr = frame_unwind_register_signed
+                            (next_frame,
+                             gdbarch_num_regs (current_gdbarch) + 30);
+
              alloca_adjust = (unsigned) (frame_addr - (sp + low_word));
              if (alloca_adjust > 0)
                {
@@ -1973,14 +1946,15 @@ restart:
       else if (inst == 0x03A0F021 || inst == 0x03a0f025 || inst == 0x03a0f02d)
        {
          /* New gcc frame, virtual frame pointer is at r30 + frame_size.  */
-         if (frame_reg == MIPS_SP_REGNUM)
+         if (next_frame && frame_reg == MIPS_SP_REGNUM)
            {
              unsigned alloca_adjust;
 
              frame_reg = 30;
-             frame_addr = read_next_frame_reg (next_frame,
-                                               gdbarch_num_regs 
-                                                 (current_gdbarch) + 30);
+             frame_addr = frame_unwind_register_signed
+                            (next_frame,
+                             gdbarch_num_regs (current_gdbarch) + 30);
+
              alloca_adjust = (unsigned) (frame_addr - sp);
              if (alloca_adjust > 0)
                {
@@ -2110,7 +2084,7 @@ mips_insn32_frame_cache (struct frame_info *next_frame, void **this_cache)
     mips32_scan_prologue (start_addr, pc, next_frame, *this_cache);
   }
   
-  /* SP_REGNUM, contains the value and not the address.  */
+  /* gdbarch_sp_regnum contains the value and not the address.  */
   trad_frame_set_value (cache->saved_regs,
                        gdbarch_num_regs (current_gdbarch) + MIPS_SP_REGNUM,
                        cache->base);
@@ -2197,7 +2171,9 @@ mips_stub_frame_cache (struct frame_info *next_frame, void **this_cache)
   (*this_cache) = this_trad_cache;
 
   /* The return address is in the link register.  */
-  trad_frame_set_reg_realreg (this_trad_cache, PC_REGNUM, MIPS_RA_REGNUM);
+  trad_frame_set_reg_realreg (this_trad_cache,
+                             gdbarch_pc_regnum (current_gdbarch),
+                             MIPS_RA_REGNUM);
 
   /* Frame ID, since it's a frameless / stackless function, no stack
      space is allocated and SP on entry is the current SP.  */
@@ -2288,22 +2264,6 @@ mips_stub_frame_base_sniffer (struct frame_info *next_frame)
     return NULL;
 }
 
-static CORE_ADDR
-read_next_frame_reg (struct frame_info *fi, int regno)
-{
-  /* Always a pseudo.  */
-  gdb_assert (regno >= gdbarch_num_regs (current_gdbarch));
-  if (fi == NULL)
-    {
-      LONGEST val;
-      regcache_cooked_read_signed (current_regcache, regno, &val);
-      return val;
-    }
-  else
-    return frame_unwind_register_signed (fi, regno);
-
-}
-
 /* mips_addr_bits_remove - remove useless address bits  */
 
 static CORE_ADDR
@@ -2337,12 +2297,12 @@ mips_addr_bits_remove (CORE_ADDR addr)
    the target of the coming instruction and breakpoint it.  */
 
 int
-mips_software_single_step (struct regcache *regcache)
+mips_software_single_step (struct frame_info *frame)
 {
   CORE_ADDR pc, next_pc;
 
-  pc = read_register (mips_regnum (current_gdbarch)->pc);
-  next_pc = mips_next_pc (pc);
+  pc = get_frame_pc (frame);
+  next_pc = mips_next_pc (frame, pc);
 
   insert_single_step_breakpoint (next_pc);
   return 1;
@@ -2579,7 +2539,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
        fprintf_unfiltered (gdb_stdlog,
                            "mips_eabi_push_dummy_call: struct_return reg=%d 0x%s\n",
                            argreg, paddr_nz (struct_addr));
-      write_register (argreg++, struct_addr);
+      regcache_cooked_write_unsigned (regcache, argreg++, struct_addr);
     }
 
   /* Now load as many as possible of the first arguments into
@@ -2656,14 +2616,14 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
                                    float_argreg, phex (regval, 4));
-             write_register (float_argreg++, regval);
+             regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
 
              /* Write the high word of the double to the odd register(s).  */
              regval = extract_unsigned_integer (val + 4 - low_offset, 4);
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
                                    float_argreg, phex (regval, 4));
-             write_register (float_argreg++, regval);
+             regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
            }
          else
            {
@@ -2675,7 +2635,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
                                    float_argreg, phex (regval, len));
-             write_register (float_argreg++, regval);
+             regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
            }
        }
       else
@@ -2764,7 +2724,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                    fprintf_filtered (gdb_stdlog, " - reg=%d val=%s",
                                      argreg,
                                      phex (regval, regsize));
-                 write_register (argreg, regval);
+                 regcache_cooked_write_unsigned (regcache, argreg, regval);
                  argreg++;
                }
 
@@ -2860,7 +2820,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
        fprintf_unfiltered (gdb_stdlog,
                            "mips_n32n64_push_dummy_call: struct_return reg=%d 0x%s\n",
                            argreg, paddr_nz (struct_addr));
-      write_register (argreg++, struct_addr);
+      regcache_cooked_write_unsigned (regcache, argreg++, struct_addr);
     }
 
   /* Now load as many as possible of the first arguments into
@@ -2892,12 +2852,12 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          if (mips_debug)
            fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
                                float_argreg, phex (regval, len));
-         write_register (float_argreg++, regval);
+         regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
 
          if (mips_debug)
            fprintf_unfiltered (gdb_stdlog, " - reg=%d val=%s",
                                argreg, phex (regval, len));
-         write_register (argreg, regval);
+         regcache_cooked_write_unsigned (regcache, argreg, regval);
          argreg += 1;
        }
       else
@@ -2997,7 +2957,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                    fprintf_filtered (gdb_stdlog, " - reg=%d val=%s",
                                      argreg,
                                      phex (regval, MIPS64_REGSIZE));
-                 write_register (argreg, regval);
+                 regcache_cooked_write_unsigned (regcache, argreg, regval);
                  argreg++;
                }
 
@@ -3218,7 +3178,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
        fprintf_unfiltered (gdb_stdlog,
                            "mips_o32_push_dummy_call: struct_return reg=%d 0x%s\n",
                            argreg, paddr_nz (struct_addr));
-      write_register (argreg++, struct_addr);
+      regcache_cooked_write_unsigned (regcache, argreg++, struct_addr);
       stack_offset += MIPS32_REGSIZE;
     }
 
@@ -3275,23 +3235,23 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
                                    float_argreg, phex (regval, 4));
-             write_register (float_argreg++, regval);
+             regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - reg=%d val=%s",
                                    argreg, phex (regval, 4));
-             write_register (argreg++, regval);
+             regcache_cooked_write_unsigned (regcache, argreg++, regval);
 
              /* Write the high word of the double to the odd register(s).  */
              regval = extract_unsigned_integer (val + 4 - low_offset, 4);
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
                                    float_argreg, phex (regval, 4));
-             write_register (float_argreg++, regval);
+             regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
 
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - reg=%d val=%s",
                                    argreg, phex (regval, 4));
-             write_register (argreg++, regval);
+             regcache_cooked_write_unsigned (regcache, argreg++, regval);
            }
          else
            {
@@ -3303,7 +3263,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
                                    float_argreg, phex (regval, len));
-             write_register (float_argreg++, regval);
+             regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
              /* CAGNEY: 32 bit MIPS ABI's always reserve two FP
                 registers for each argument.  The below is (my
                 guess) to ensure that the corresponding integer
@@ -3311,7 +3271,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
              if (mips_debug)
                fprintf_unfiltered (gdb_stdlog, " - reg=%d val=%s",
                                    argreg, phex (regval, len));
-             write_register (argreg, regval);
+             regcache_cooked_write_unsigned (regcache, argreg, regval);
              argreg += 2;
            }
          /* Reserve space for the FP register.  */
@@ -3429,7 +3389,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                    fprintf_filtered (gdb_stdlog, " - reg=%d val=%s",
                                      argreg,
                                      phex (regval, MIPS32_REGSIZE));
-                 write_register (argreg, regval);
+                 regcache_cooked_write_unsigned (regcache, argreg, regval);
                  argreg++;
 
                  /* Prevent subsequent floating point arguments from
@@ -3677,7 +3637,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
        fprintf_unfiltered (gdb_stdlog,
                            "mips_o64_push_dummy_call: struct_return reg=%d 0x%s\n",
                            argreg, paddr_nz (struct_addr));
-      write_register (argreg++, struct_addr);
+      regcache_cooked_write_unsigned (regcache, argreg++, struct_addr);
       stack_offset += MIPS64_REGSIZE;
     }
 
@@ -3716,11 +3676,11 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          if (mips_debug)
            fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
                                float_argreg, phex (regval, len));
-         write_register (float_argreg++, regval);
+         regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
          if (mips_debug)
            fprintf_unfiltered (gdb_stdlog, " - reg=%d val=%s",
                                argreg, phex (regval, len));
-         write_register (argreg, regval);
+         regcache_cooked_write_unsigned (regcache, argreg, regval);
          argreg++;
          /* Reserve space for the FP register.  */
          stack_offset += align_up (len, MIPS64_REGSIZE);
@@ -3818,7 +3778,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                    fprintf_filtered (gdb_stdlog, " - reg=%d val=%s",
                                      argreg,
                                      phex (regval, MIPS64_REGSIZE));
-                 write_register (argreg, regval);
+                 regcache_cooked_write_unsigned (regcache, argreg, regval);
                  argreg++;
 
                  /* Prevent subsequent floating point arguments from
@@ -3984,7 +3944,7 @@ mips_read_fp_register_double (struct frame_info *frame, int regno,
 {
   int raw_size = register_size (current_gdbarch, regno);
 
-  if (raw_size == 8 && !mips2_fp_compat ())
+  if (raw_size == 8 && !mips2_fp_compat (frame))
     {
       /* We have a 64-bit value for this register, and we should use
          all 64 bits.  */
@@ -4032,7 +3992,7 @@ mips_print_fp_register (struct ui_file *file, struct frame_info *frame,
                                        (current_gdbarch, regnum)),
                    "");
 
-  if (register_size (current_gdbarch, regnum) == 4 || mips2_fp_compat ())
+  if (register_size (current_gdbarch, regnum) == 4 || mips2_fp_compat (frame))
     {
       /* 4-byte registers: Print hex and floating.  Also print even
          numbered registers as doubles.  */
@@ -4474,7 +4434,7 @@ deprecated_mips_set_processor_regs_hack (void)
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   ULONGEST prid;
 
-  regcache_cooked_read_unsigned (current_regcache,
+  regcache_cooked_read_unsigned (get_current_regcache (),
                                 MIPS_PRID_REGNUM, &prid);
   if ((prid & ~0xf) == 0x700)
     tdep->mips_processor_reg_names = mips_r3041_reg_names;
@@ -4617,7 +4577,7 @@ mips_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
    gory details.  */
 
 static CORE_ADDR
-mips_skip_trampoline_code (CORE_ADDR pc)
+mips_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
 {
   char *name;
   CORE_ADDR start_addr;
@@ -4630,14 +4590,14 @@ mips_skip_trampoline_code (CORE_ADDR pc)
      target PC is in $31 ($ra).  */
   if (strcmp (name, "__mips16_ret_sf") == 0
       || strcmp (name, "__mips16_ret_df") == 0)
-    return read_signed_register (MIPS_RA_REGNUM);
+    return get_frame_register_signed (frame, MIPS_RA_REGNUM);
 
   if (strncmp (name, "__mips16_call_stub_", 19) == 0)
     {
       /* If the PC is in __mips16_call_stub_{1..10}, this is a call stub
          and the target PC is in $2.  */
       if (name[19] >= '0' && name[19] <= '9')
-       return read_signed_register (2);
+       return get_frame_register_signed (frame, 2);
 
       /* If the PC at the start of __mips16_call_stub_{s,d}f_{0..10}, i.e.
          before the jal instruction, this is effectively a call stub
@@ -4659,7 +4619,7 @@ mips_skip_trampoline_code (CORE_ADDR pc)
                 So scan down to the lui/addi and extract the target
                 address from those two instructions.  */
 
-             CORE_ADDR target_pc = read_signed_register (2);
+             CORE_ADDR target_pc = get_frame_register_signed (frame, 2);
              ULONGEST inst;
              int i;
 
@@ -4690,7 +4650,7 @@ mips_skip_trampoline_code (CORE_ADDR pc)
          else
            /* This is the 'return' part of a call stub.  The return
               address is in $r18.  */
-           return read_signed_register (18);
+           return get_frame_register_signed (frame, 18);
        }
     }
   return 0;                    /* not a stub */
@@ -5235,7 +5195,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        else
          reg_names = mips_generic_reg_names;
       }
-    /* FIXME: cagney/2003-11-15: For MIPS, hasn't PC_REGNUM been
+    /* FIXME: cagney/2003-11-15: For MIPS, hasn't gdbarch_pc_regnum been
        replaced by read_pc?  */
     set_gdbarch_pc_regnum (gdbarch, regnum->pc + num_regs);
     set_gdbarch_sp_regnum (gdbarch, MIPS_SP_REGNUM + num_regs);