diff --git a/gdb/regcache.c b/gdb/regcache.c
index e0554c7..f4fcf65 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -187,51 +187,12 @@ regcache_register_size (const struct regcache *regcache, int n)
   return register_size (get_regcache_arch (regcache), n);
 }
 
-/* The register cache for storing raw register values.  */
-
-struct regcache
+regcache::regcache (struct gdbarch *gdbarch, struct address_space *aspace_,
+		    bool readonly_p_)
+  : aspace (aspace_), readonly_p (readonly_p_)
 {
-public:
-  explicit regcache (struct gdbarch *gdbarch, struct address_space *aspace_)
-    : regcache (gdbarch, aspace_, true)
-  {}
-
-  ~regcache ()
-  {
-    xfree (registers);
-    xfree (register_status);
-  }
-
-  struct regcache_descr *descr;
-
-  /* The address space of this register cache (for registers where it
-     makes sense, like PC or SP).  */
-  struct address_space *aspace;
-
-  /* The register buffers.  A read-only register cache can hold the
-     full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a read/write
-     register cache can only hold [0 .. gdbarch_num_regs).  */
-  gdb_byte *registers;
-  /* Register cache status.  */
-  signed char *register_status;
-  /* Is this a read-only cache?  A read-only cache is used for saving
-     the target's register state (e.g, across an inferior function
-     call or just before forcing a function return).  A read-only
-     cache can only be updated via the methods regcache_dup() and
-     regcache_cpy().  The actual contents are determined by the
-     reggroup_save and reggroup_restore methods.  */
-  bool readonly_p;
-  /* If this is a read-write cache, which thread's registers is
-     it connected to?  */
-  ptid_t ptid;
-
-private:
-  explicit regcache (struct gdbarch *gdbarch, struct address_space *aspace_,
-		     bool readonly_p_)
-    : aspace (aspace_), readonly_p (readonly_p_)
-  {
-    gdb_assert (gdbarch != NULL);
-    descr = regcache_descr (gdbarch);
+  gdb_assert (gdbarch != NULL);
+  descr = regcache_descr (gdbarch);
 
   if (readonly_p)
     {
@@ -246,21 +207,22 @@ private:
 				  descr->sizeof_raw_register_status);
     }
   ptid = minus_one_ptid;
-  }
+}
 
-  friend struct regcache *
-  get_thread_arch_aspace_regcache (ptid_t ptid, struct gdbarch *gdbarch,
-				   struct address_space *aspace);
-};
+struct gdbarch *
+regcache::get_arch () const
+{
+  return descr->gdbarch;
+}
 
 /* See regcache.h.  */
 
 ptid_t
 regcache_get_ptid (const struct regcache *regcache)
 {
-  gdb_assert (!ptid_equal (regcache->ptid, minus_one_ptid));
+  gdb_assert (!ptid_equal (regcache->get_ptid (), minus_one_ptid));
 
-  return regcache->ptid;
+  return regcache->get_ptid ();
 }
 
 struct regcache *
@@ -321,84 +283,90 @@ make_cleanup_regcache_invalidate (struct regcache *regcache, int regnum)
 struct gdbarch *
 get_regcache_arch (const struct regcache *regcache)
 {
-  return regcache->descr->gdbarch;
+  return regcache->get_arch ();
 }
 
 struct address_space *
 get_regcache_aspace (const struct regcache *regcache)
 {
-  return regcache->aspace;
+  return regcache->get_aspace ();
 }
 
 /* Return  a pointer to register REGNUM's buffer cache.  */
 
-static gdb_byte *
-register_buffer (const struct regcache *regcache, int regnum)
+gdb_byte *
+regcache::register_buffer (int regnum) const
 {
-  return regcache->registers + regcache->descr->register_offset[regnum];
+  return registers + descr->register_offset[regnum];
 }
 
 void
-regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read,
-	       void *src)
+regcache_save (struct regcache *regcache,
+	       regcache_cooked_read_ftype *cooked_read, void *src)
 {
-  struct gdbarch *gdbarch = dst->descr->gdbarch;
+  regcache->save (cooked_read, src);
+}
+
+void
+regcache::save (regcache_cooked_read_ftype *cooked_read,
+		void *src)
+{
+  struct gdbarch *gdbarch = descr->gdbarch;
   gdb_byte buf[MAX_REGISTER_SIZE];
   int regnum;
 
   /* The DST should be `read-only', if it wasn't then the save would
      end up trying to write the register values back out to the
      target.  */
-  gdb_assert (dst->readonly_p);
+  gdb_assert (readonly_p);
   /* Clear the dest.  */
-  memset (dst->registers, 0, dst->descr->sizeof_cooked_registers);
-  memset (dst->register_status, 0,
-	  dst->descr->sizeof_cooked_register_status);
+  memset (registers, 0, descr->sizeof_cooked_registers);
+  memset (register_status, 0, descr->sizeof_cooked_register_status);
   /* Copy over any registers (identified by their membership in the
      save_reggroup) and mark them as valid.  The full [0 .. gdbarch_num_regs +
      gdbarch_num_pseudo_regs) range is checked since some architectures need
      to save/restore `cooked' registers that live in memory.  */
-  for (regnum = 0; regnum < dst->descr->nr_cooked_registers; regnum++)
+  for (regnum = 0; regnum < descr->nr_cooked_registers; regnum++)
     {
       if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup))
 	{
 	  enum register_status status = cooked_read (src, regnum, buf);
 
 	  if (status == REG_VALID)
-	    memcpy (register_buffer (dst, regnum), buf,
+	    memcpy (register_buffer (regnum), buf,
 		    register_size (gdbarch, regnum));
 	  else
 	    {
 	      gdb_assert (status != REG_UNKNOWN);
 
-	      memset (register_buffer (dst, regnum), 0,
+	      memset (register_buffer (regnum), 0,
 		      register_size (gdbarch, regnum));
 	    }
-	  dst->register_status[regnum] = status;
+	  register_status[regnum] = status;
 	}
     }
 }
 
-static void
-regcache_restore (struct regcache *dst, struct regcache *src)
+void
+regcache::restore (struct regcache *src)
 {
-  struct gdbarch *gdbarch = dst->descr->gdbarch;
+  struct gdbarch *gdbarch = descr->gdbarch;
   int regnum;
 
   /* The dst had better not be read-only.  If it is, the `restore'
      doesn't make much sense.  */
-  gdb_assert (!dst->readonly_p);
+  gdb_assert (!readonly_p);
   gdb_assert (src->readonly_p);
   /* Copy over any registers, being careful to only restore those that
      were both saved and need to be restored.  The full [0 .. gdbarch_num_regs
      + gdbarch_num_pseudo_regs) range is checked since some architectures need
      to save/restore `cooked' registers that live in memory.  */
-  for (regnum = 0; regnum < dst->descr->nr_cooked_registers; regnum++)
+  for (regnum = 0; regnum < descr->nr_cooked_registers; regnum++)
     {
       if (gdbarch_register_reggroup_p (gdbarch, regnum, restore_reggroup))
 	{
 	  if (src->register_status[regnum] == REG_VALID)
-	    regcache_cooked_write (dst, regnum, register_buffer (src, regnum));
+	    cooked_write (regnum, src->register_buffer (regnum));
 	}
     }
 }
@@ -411,9 +379,6 @@ do_cooked_read (void *src, int regnum, gdb_byte *buf)
   return regcache_cooked_read (regcache, regnum, buf);
 }
 
-static void regcache_cpy_no_passthrough (struct regcache *dst,
-					 struct regcache *src);
-
 void
 regcache_cpy (struct regcache *dst, struct regcache *src)
 {
@@ -425,9 +390,9 @@ regcache_cpy (struct regcache *dst, struct regcache *src)
   if (!src->readonly_p)
     regcache_save (dst, do_cooked_read, src);
   else if (!dst->readonly_p)
-    regcache_restore (dst, src);
+    dst->restore (src);
   else
-    regcache_cpy_no_passthrough (dst, src);
+    dst->cpy_no_passthrough (src);
 }
 
 /* Copy/duplicate the contents of a register cache.  Unlike regcache_cpy,
@@ -435,21 +400,21 @@ regcache_cpy (struct regcache *dst, struct regcache *src)
    Only values values already in the cache are transferred.  The SRC and DST
    buffers must not overlap.  */
 
-static void
-regcache_cpy_no_passthrough (struct regcache *dst, struct regcache *src)
+void
+regcache::cpy_no_passthrough (struct regcache *src)
 {
-  gdb_assert (src != NULL && dst != NULL);
-  gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
+  gdb_assert (src != NULL);
+  gdb_assert (src->descr->gdbarch == descr->gdbarch);
   /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
      move of data into a thread's regcache.  Doing this would be silly
      - it would mean that regcache->register_status would be
      completely invalid.  */
-  gdb_assert (dst->readonly_p && src->readonly_p);
+  gdb_assert (readonly_p && src->readonly_p);
 
-  memcpy (dst->registers, src->registers,
-	  dst->descr->sizeof_cooked_registers);
-  memcpy (dst->register_status, src->register_status,
-	  dst->descr->sizeof_cooked_register_status);
+  memcpy (registers, src->registers,
+	  descr->sizeof_cooked_registers);
+  memcpy (register_status, src->register_status,
+	  descr->sizeof_cooked_register_status);
 }
 
 struct regcache *
@@ -457,7 +422,7 @@ regcache_dup (struct regcache *src)
 {
   struct regcache *newbuf;
 
-  newbuf = regcache_xmalloc (src->descr->gdbarch, get_regcache_aspace (src));
+  newbuf = regcache_xmalloc (src->get_arch (), get_regcache_aspace (src));
   regcache_cpy (newbuf, src);
   return newbuf;
 }
@@ -466,25 +431,36 @@ enum register_status
 regcache_register_status (const struct regcache *regcache, int regnum)
 {
   gdb_assert (regcache != NULL);
+  return regcache->get_register_status (regnum);
+}
+
+enum register_status
+regcache::get_register_status (int regnum) const
+{
   gdb_assert (regnum >= 0);
-  if (regcache->readonly_p)
-    gdb_assert (regnum < regcache->descr->nr_cooked_registers);
+  if (readonly_p)
+    gdb_assert (regnum < descr->nr_cooked_registers);
   else
-    gdb_assert (regnum < regcache->descr->nr_raw_registers);
+    gdb_assert (regnum < descr->nr_raw_registers);
 
-  return (enum register_status) regcache->register_status[regnum];
+  return (enum register_status) register_status[regnum];
 }
 
 void
 regcache_invalidate (struct regcache *regcache, int regnum)
 {
   gdb_assert (regcache != NULL);
-  gdb_assert (regnum >= 0);
-  gdb_assert (!regcache->readonly_p);
-  gdb_assert (regnum < regcache->descr->nr_raw_registers);
-  regcache->register_status[regnum] = REG_UNKNOWN;
+  regcache->invalidate (regnum);
 }
 
+void
+regcache::invalidate (int regnum)
+{
+  gdb_assert (regnum >= 0);
+  gdb_assert (!readonly_p);
+  gdb_assert (regnum < descr->nr_raw_registers);
+  register_status[regnum] = REG_UNKNOWN;
+}
 
 /* Global structure containing the current regcache.  */
 
@@ -587,8 +563,8 @@ regcache_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid)
   struct regcache_list *list;
 
   for (list = current_regcache; list; list = list->next)
-    if (ptid_equal (list->regcache->ptid, old_ptid))
-      list->regcache->ptid = new_ptid;
+    if (ptid_equal (list->regcache->get_ptid (), old_ptid))
+      list->regcache->set_ptid (new_ptid);
 }
 
 /* Low level examining and depositing of registers.
@@ -611,7 +587,7 @@ registers_changed_ptid (ptid_t ptid)
   list_link = &current_regcache;
   while (list)
     {
-      if (ptid_match (list->regcache->ptid, ptid))
+      if (ptid_match (list->regcache->get_ptid (), ptid))
 	{
 	  struct regcache_list *dead = list;
 
@@ -657,55 +633,73 @@ void
 regcache_raw_update (struct regcache *regcache, int regnum)
 {
   gdb_assert (regcache != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+
+  regcache->raw_update (regnum);
+}
+
+void
+regcache::raw_update (int regnum)
+{
+  gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
 
   /* Make certain that the register cache is up-to-date with respect
      to the current thread.  This switching shouldn't be necessary
      only there is still only one target side register cache.  Sigh!
      On the bright side, at least there is a regcache object.  */
 
-  if (!regcache->readonly_p
-      && regcache_register_status (regcache, regnum) == REG_UNKNOWN)
+  if (!readonly_p && get_register_status (regnum) == REG_UNKNOWN)
     {
-      target_fetch_registers (regcache, regnum);
+      target_fetch_registers (this, regnum);
 
       /* A number of targets can't access the whole set of raw
 	 registers (because the debug API provides no means to get at
 	 them).  */
-      if (regcache->register_status[regnum] == REG_UNKNOWN)
-	regcache->register_status[regnum] = REG_UNAVAILABLE;
+      if (register_status[regnum] == REG_UNKNOWN)
+	register_status[regnum] = REG_UNAVAILABLE;
     }
 }
 
 enum register_status
 regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf)
 {
+  return regcache->raw_read (regnum, buf);
+}
+
+enum register_status
+regcache::raw_read (int regnum, gdb_byte *buf)
+{
   gdb_assert (buf != NULL);
-  regcache_raw_update (regcache, regnum);
+  raw_update (regnum);
 
-  if (regcache->register_status[regnum] != REG_VALID)
-    memset (buf, 0, regcache->descr->sizeof_register[regnum]);
+  if (register_status[regnum] != REG_VALID)
+    memset (buf, 0, descr->sizeof_register[regnum]);
   else
-    memcpy (buf, register_buffer (regcache, regnum),
-	    regcache->descr->sizeof_register[regnum]);
+    memcpy (buf, register_buffer (regnum),
+	    descr->sizeof_register[regnum]);
 
-  return (enum register_status) regcache->register_status[regnum];
+  return (enum register_status) register_status[regnum];
 }
 
 enum register_status
 regcache_raw_read_signed (struct regcache *regcache, int regnum, LONGEST *val)
 {
+  gdb_assert (regcache != NULL);
+  return regcache->raw_read_signed (regnum, val);
+}
+
+enum register_status
+regcache::raw_read_signed (int regnum, LONGEST *val)
+{
   gdb_byte *buf;
   enum register_status status;
 
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
-  buf = (gdb_byte *) alloca (regcache->descr->sizeof_register[regnum]);
-  status = regcache_raw_read (regcache, regnum, buf);
+  gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
+  buf = (gdb_byte *) alloca (descr->sizeof_register[regnum]);
+  status = raw_read (regnum, buf);
   if (status == REG_VALID)
     *val = extract_signed_integer
-      (buf, regcache->descr->sizeof_register[regnum],
-       gdbarch_byte_order (regcache->descr->gdbarch));
+      (buf, descr->sizeof_register[regnum],
+       gdbarch_byte_order (descr->gdbarch));
   else
     *val = 0;
   return status;
@@ -715,17 +709,24 @@ enum register_status
 regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
 			    ULONGEST *val)
 {
+  gdb_assert (regcache != NULL);
+  return regcache->raw_read_unsigned (regnum, val);
+}
+
+
+enum register_status
+regcache::raw_read_unsigned (int regnum, ULONGEST *val)
+{
   gdb_byte *buf;
   enum register_status status;
 
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
-  buf = (gdb_byte *) alloca (regcache->descr->sizeof_register[regnum]);
-  status = regcache_raw_read (regcache, regnum, buf);
+  gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
+  buf = (gdb_byte *) alloca (descr->sizeof_register[regnum]);
+  status = raw_read (regnum, buf);
   if (status == REG_VALID)
     *val = extract_unsigned_integer
-      (buf, regcache->descr->sizeof_register[regnum],
-       gdbarch_byte_order (regcache->descr->gdbarch));
+      (buf, descr->sizeof_register[regnum],
+       gdbarch_byte_order (descr->gdbarch));
   else
     *val = 0;
   return status;
@@ -734,28 +735,40 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
 void
 regcache_raw_write_signed (struct regcache *regcache, int regnum, LONGEST val)
 {
+  gdb_assert (regcache != NULL);
+  regcache->raw_write_signed (regnum, val);
+}
+
+void
+regcache::raw_write_signed (int regnum, LONGEST val)
+{
   gdb_byte *buf;
 
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
-  buf = (gdb_byte *) alloca (regcache->descr->sizeof_register[regnum]);
-  store_signed_integer (buf, regcache->descr->sizeof_register[regnum],
-			gdbarch_byte_order (regcache->descr->gdbarch), val);
-  regcache_raw_write (regcache, regnum, buf);
+  gdb_assert (regnum >=0 && regnum < descr->nr_raw_registers);
+  buf = (gdb_byte *) alloca (descr->sizeof_register[regnum]);
+  store_signed_integer (buf, descr->sizeof_register[regnum],
+			gdbarch_byte_order (descr->gdbarch), val);
+  raw_write (regnum, buf);
 }
 
 void
 regcache_raw_write_unsigned (struct regcache *regcache, int regnum,
 			     ULONGEST val)
 {
+  gdb_assert (regcache != NULL);
+  regcache->raw_write_unsigned (regnum, val);
+}
+
+void
+regcache::raw_write_unsigned (int regnum, ULONGEST val)
+{
   gdb_byte *buf;
 
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
-  buf = (gdb_byte *) alloca (regcache->descr->sizeof_register[regnum]);
-  store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum],
-			  gdbarch_byte_order (regcache->descr->gdbarch), val);
-  regcache_raw_write (regcache, regnum, buf);
+  gdb_assert (regnum >=0 && regnum < descr->nr_raw_registers);
+  buf = (gdb_byte *) alloca (descr->sizeof_register[regnum]);
+  store_unsigned_integer (buf, descr->sizeof_register[regnum],
+			  gdbarch_byte_order (descr->gdbarch), val);
+  raw_write (regnum, buf);
 }
 
 LONGEST
@@ -774,38 +787,44 @@ regcache_raw_get_signed (struct regcache *regcache, int regnum)
 enum register_status
 regcache_cooked_read (struct regcache *regcache, int regnum, gdb_byte *buf)
 {
+  return regcache->cooked_read (regnum, buf);
+}
+
+enum register_status
+regcache::cooked_read (int regnum, gdb_byte *buf)
+{
   gdb_assert (regnum >= 0);
-  gdb_assert (regnum < regcache->descr->nr_cooked_registers);
-  if (regnum < regcache->descr->nr_raw_registers)
-    return regcache_raw_read (regcache, regnum, buf);
-  else if (regcache->readonly_p
-	   && regcache->register_status[regnum] != REG_UNKNOWN)
+  gdb_assert (regnum < descr->nr_cooked_registers);
+  if (regnum < descr->nr_raw_registers)
+    return raw_read (regnum, buf);
+  else if (readonly_p
+	   && register_status[regnum] != REG_UNKNOWN)
     {
       /* Read-only register cache, perhaps the cooked value was
 	 cached?  */
-      if (regcache->register_status[regnum] == REG_VALID)
-	memcpy (buf, register_buffer (regcache, regnum),
-		regcache->descr->sizeof_register[regnum]);
+      if (register_status[regnum] == REG_VALID)
+	memcpy (buf, register_buffer (regnum),
+		descr->sizeof_register[regnum]);
       else
-	memset (buf, 0, regcache->descr->sizeof_register[regnum]);
+	memset (buf, 0, descr->sizeof_register[regnum]);
 
-      return (enum register_status) regcache->register_status[regnum];
+      return (enum register_status) register_status[regnum];
     }
-  else if (gdbarch_pseudo_register_read_value_p (regcache->descr->gdbarch))
+  else if (gdbarch_pseudo_register_read_value_p (descr->gdbarch))
     {
       struct value *mark, *computed;
       enum register_status result = REG_VALID;
 
       mark = value_mark ();
 
-      computed = gdbarch_pseudo_register_read_value (regcache->descr->gdbarch,
-						     regcache, regnum);
+      computed = gdbarch_pseudo_register_read_value (descr->gdbarch,
+						     this, regnum);
       if (value_entirely_available (computed))
 	memcpy (buf, value_contents_raw (computed),
-		regcache->descr->sizeof_register[regnum]);
+		descr->sizeof_register[regnum]);
       else
 	{
-	  memset (buf, 0, regcache->descr->sizeof_register[regnum]);
+	  memset (buf, 0, descr->sizeof_register[regnum]);
 	  result = REG_UNAVAILABLE;
 	}
 
@@ -814,58 +833,68 @@ regcache_cooked_read (struct regcache *regcache, int regnum, gdb_byte *buf)
       return result;
     }
   else
-    return gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache,
+    return gdbarch_pseudo_register_read (descr->gdbarch, this,
 					 regnum, buf);
 }
 
 struct value *
 regcache_cooked_read_value (struct regcache *regcache, int regnum)
 {
+  return regcache->cooked_read_value (regnum);
+}
+
+struct value *
+regcache::cooked_read_value (int regnum)
+{
   gdb_assert (regnum >= 0);
-  gdb_assert (regnum < regcache->descr->nr_cooked_registers);
+  gdb_assert (regnum < descr->nr_cooked_registers);
 
-  if (regnum < regcache->descr->nr_raw_registers
-      || (regcache->readonly_p
-	  && regcache->register_status[regnum] != REG_UNKNOWN)
-      || !gdbarch_pseudo_register_read_value_p (regcache->descr->gdbarch))
+  if (regnum < descr->nr_raw_registers
+      || (readonly_p && register_status[regnum] != REG_UNKNOWN)
+      || !gdbarch_pseudo_register_read_value_p (descr->gdbarch))
     {
       struct value *result;
 
-      result = allocate_value (register_type (regcache->descr->gdbarch,
-					      regnum));
+      result = allocate_value (register_type (descr->gdbarch, regnum));
       VALUE_LVAL (result) = lval_register;
       VALUE_REGNUM (result) = regnum;
 
       /* It is more efficient in general to do this delegation in this
 	 direction than in the other one, even though the value-based
 	 API is preferred.  */
-      if (regcache_cooked_read (regcache, regnum,
-				value_contents_raw (result)) == REG_UNAVAILABLE)
+      if (cooked_read (regnum,
+		       value_contents_raw (result)) == REG_UNAVAILABLE)
 	mark_value_bytes_unavailable (result, 0,
 				      TYPE_LENGTH (value_type (result)));
 
       return result;
     }
   else
-    return gdbarch_pseudo_register_read_value (regcache->descr->gdbarch,
-					       regcache, regnum);
+    return gdbarch_pseudo_register_read_value (descr->gdbarch,
+					       this, regnum);
 }
 
 enum register_status
 regcache_cooked_read_signed (struct regcache *regcache, int regnum,
 			     LONGEST *val)
 {
+  gdb_assert (regcache != NULL);
+  return regcache->cooked_read_signed (regnum, val);
+}
+
+enum register_status
+regcache::cooked_read_signed (int regnum, LONGEST *val)
+{
   enum register_status status;
   gdb_byte *buf;
 
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
-  buf = (gdb_byte *) alloca (regcache->descr->sizeof_register[regnum]);
-  status = regcache_cooked_read (regcache, regnum, buf);
+  gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
+  buf = (gdb_byte *) alloca (descr->sizeof_register[regnum]);
+  status = cooked_read (regnum, buf);
   if (status == REG_VALID)
     *val = extract_signed_integer
-      (buf, regcache->descr->sizeof_register[regnum],
-       gdbarch_byte_order (regcache->descr->gdbarch));
+      (buf, descr->sizeof_register[regnum],
+       gdbarch_byte_order (descr->gdbarch));
   else
     *val = 0;
   return status;
@@ -875,17 +904,23 @@ enum register_status
 regcache_cooked_read_unsigned (struct regcache *regcache, int regnum,
 			       ULONGEST *val)
 {
+  gdb_assert (regcache != NULL);
+  return regcache->cooked_read_unsigned (regnum, val);
+}
+
+enum register_status
+regcache::cooked_read_unsigned (int regnum, ULONGEST *val)
+{
   enum register_status status;
   gdb_byte *buf;
 
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
-  buf = (gdb_byte *) alloca (regcache->descr->sizeof_register[regnum]);
-  status = regcache_cooked_read (regcache, regnum, buf);
+  gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
+  buf = (gdb_byte *) alloca (descr->sizeof_register[regnum]);
+  status = cooked_read (regnum, buf);
   if (status == REG_VALID)
     *val = extract_unsigned_integer
-      (buf, regcache->descr->sizeof_register[regnum],
-       gdbarch_byte_order (regcache->descr->gdbarch));
+      (buf, descr->sizeof_register[regnum],
+       gdbarch_byte_order (descr->gdbarch));
   else
     *val = 0;
   return status;
@@ -895,28 +930,40 @@ void
 regcache_cooked_write_signed (struct regcache *regcache, int regnum,
 			      LONGEST val)
 {
+  gdb_assert (regcache != NULL);
+  regcache->cooked_write_signed (regnum, val);
+}
+
+void
+regcache::cooked_write_signed (int regnum, LONGEST val)
+{
   gdb_byte *buf;
 
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
-  buf = (gdb_byte *) alloca (regcache->descr->sizeof_register[regnum]);
-  store_signed_integer (buf, regcache->descr->sizeof_register[regnum],
-			gdbarch_byte_order (regcache->descr->gdbarch), val);
-  regcache_cooked_write (regcache, regnum, buf);
+  gdb_assert (regnum >=0 && regnum < descr->nr_cooked_registers);
+  buf = (gdb_byte *) alloca (descr->sizeof_register[regnum]);
+  store_signed_integer (buf, descr->sizeof_register[regnum],
+			gdbarch_byte_order (descr->gdbarch), val);
+  cooked_write (regnum, buf);
 }
 
 void
 regcache_cooked_write_unsigned (struct regcache *regcache, int regnum,
 				ULONGEST val)
 {
+  gdb_assert (regcache != NULL);
+  regcache->cooked_write_unsigned (regnum, val);
+}
+
+void
+regcache::cooked_write_unsigned (int regnum, ULONGEST val)
+{
   gdb_byte *buf;
 
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
-  buf = (gdb_byte *) alloca (regcache->descr->sizeof_register[regnum]);
-  store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum],
-			  gdbarch_byte_order (regcache->descr->gdbarch), val);
-  regcache_cooked_write (regcache, regnum, buf);
+  gdb_assert (regnum >=0 && regnum < descr->nr_cooked_registers);
+  buf = (gdb_byte *) alloca (descr->sizeof_register[regnum]);
+  store_unsigned_integer (buf, descr->sizeof_register[regnum],
+			  gdbarch_byte_order (descr->gdbarch), val);
+  cooked_write (regnum, buf);
 }
 
 /* See regcache.h.  */
@@ -925,41 +972,54 @@ void
 regcache_raw_set_cached_value (struct regcache *regcache, int regnum,
 			       const gdb_byte *buf)
 {
-  memcpy (register_buffer (regcache, regnum), buf,
-	  regcache->descr->sizeof_register[regnum]);
-  regcache->register_status[regnum] = REG_VALID;
+  regcache->raw_set_cached_value (regnum, buf);
+}
+
+void
+regcache::raw_set_cached_value (int regnum, const gdb_byte *buf)
+{
+  memcpy (register_buffer (regnum), buf,
+	  descr->sizeof_register[regnum]);
+  register_status[regnum] = REG_VALID;
 }
 
 void
 regcache_raw_write (struct regcache *regcache, int regnum,
 		    const gdb_byte *buf)
 {
+  gdb_assert (regcache != NULL && buf != NULL);
+  regcache->raw_write (regnum, buf);
+}
+
+void
+regcache::raw_write (int regnum, const gdb_byte *buf)
+{
   struct cleanup *old_chain;
 
-  gdb_assert (regcache != NULL && buf != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
-  gdb_assert (!regcache->readonly_p);
+  gdb_assert (buf != NULL);
+  gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
+  gdb_assert (!readonly_p);
 
   /* On the sparc, writing %g0 is a no-op, so we don't even want to
      change the registers array if something writes to this register.  */
-  if (gdbarch_cannot_store_register (get_regcache_arch (regcache), regnum))
+  if (gdbarch_cannot_store_register (get_arch (), regnum))
     return;
 
   /* If we have a valid copy of the register, and new value == old
      value, then don't bother doing the actual store.  */
-  if (regcache_register_status (regcache, regnum) == REG_VALID
-      && (memcmp (register_buffer (regcache, regnum), buf,
-		  regcache->descr->sizeof_register[regnum]) == 0))
+  if (get_register_status (regnum) == REG_VALID
+      && (memcmp (register_buffer (regnum), buf,
+		  descr->sizeof_register[regnum]) == 0))
     return;
 
-  target_prepare_to_store (regcache);
-  regcache_raw_set_cached_value (regcache, regnum, buf);
+  target_prepare_to_store (this);
+  raw_set_cached_value (regnum, buf);
 
   /* Register a cleanup function for invalidating the register after it is
      written, in case of a failure.  */
-  old_chain = make_cleanup_regcache_invalidate (regcache, regnum);
+  old_chain = make_cleanup_regcache_invalidate (this, regnum);
 
-  target_store_registers (regcache, regnum);
+  target_store_registers (this, regnum);
 
   /* The target did not throw an error so we can discard invalidating the
      register and restore the cleanup chain to what it was.  */
@@ -970,12 +1030,18 @@ void
 regcache_cooked_write (struct regcache *regcache, int regnum,
 		       const gdb_byte *buf)
 {
+  regcache->cooked_write (regnum, buf);
+}
+
+void
+regcache::cooked_write (int regnum, const gdb_byte *buf)
+{
   gdb_assert (regnum >= 0);
-  gdb_assert (regnum < regcache->descr->nr_cooked_registers);
-  if (regnum < regcache->descr->nr_raw_registers)
-    regcache_raw_write (regcache, regnum, buf);
+  gdb_assert (regnum < descr->nr_cooked_registers);
+  if (regnum < descr->nr_raw_registers)
+    raw_write (regnum, buf);
   else
-    gdbarch_pseudo_register_write (regcache->descr->gdbarch, regcache,
+    gdbarch_pseudo_register_write (descr->gdbarch, this,
 				   regnum, buf);
 }
 
@@ -987,17 +1053,16 @@ typedef void (regcache_read_ftype) (struct regcache *regcache, int regnum,
 typedef void (regcache_write_ftype) (struct regcache *regcache, int regnum,
 				     const void *buf);
 
-static enum register_status
-regcache_xfer_part (struct regcache *regcache, int regnum,
-		    int offset, int len, void *in, const void *out,
-		    enum register_status (*read) (struct regcache *regcache,
-						  int regnum,
-						  gdb_byte *buf),
-		    void (*write) (struct regcache *regcache, int regnum,
-				   const gdb_byte *buf))
-{
-  struct regcache_descr *descr = regcache->descr;
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+enum register_status
+regcache::xfer_part (int regnum, int offset, int len, void *in,
+		     const void *out,
+		     enum register_status (*read) (struct regcache *regcache,
+						   int regnum,
+						   gdb_byte *buf),
+		     void (*write) (struct regcache *regcache, int regnum,
+				    const gdb_byte *buf))
+{
+  struct gdbarch *gdbarch = get_arch ();
   gdb_byte *reg = (gdb_byte *) alloca (register_size (gdbarch, regnum));
 
   gdb_assert (offset >= 0 && offset <= descr->sizeof_register[regnum]);
@@ -1013,7 +1078,7 @@ regcache_xfer_part (struct regcache *regcache, int regnum,
       enum register_status status;
 
       gdb_assert (read != NULL);
-      status = read (regcache, regnum, reg);
+      status = read (this, regnum, reg);
       if (status != REG_VALID)
 	return status;
     }
@@ -1026,7 +1091,7 @@ regcache_xfer_part (struct regcache *regcache, int regnum,
   if (out != NULL)
     {
       gdb_assert (write != NULL);
-      write (regcache, regnum, reg);
+      write (this, regnum, reg);
     }
 
   return REG_VALID;
@@ -1036,44 +1101,63 @@ enum register_status
 regcache_raw_read_part (struct regcache *regcache, int regnum,
 			int offset, int len, gdb_byte *buf)
 {
-  struct regcache_descr *descr = regcache->descr;
+  return regcache->raw_read_part (regnum, offset, len, buf);
+}
 
+enum register_status
+regcache::raw_read_part (int regnum, int offset, int len, gdb_byte *buf)
+{
   gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
-  return regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
-			     regcache_raw_read, regcache_raw_write);
+  return xfer_part (regnum, offset, len, buf, NULL,
+		    regcache_raw_read, regcache_raw_write);
 }
 
 void
 regcache_raw_write_part (struct regcache *regcache, int regnum,
 			 int offset, int len, const gdb_byte *buf)
 {
-  struct regcache_descr *descr = regcache->descr;
+  regcache->raw_write_part (regnum, offset, len, buf);
+}
 
+void
+regcache::raw_write_part (int regnum, int offset, int len,
+			  const gdb_byte *buf)
+{
   gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
-  regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
-		      regcache_raw_read, regcache_raw_write);
+  xfer_part (regnum, offset, len, NULL, buf, regcache_raw_read,
+	     regcache_raw_write);
 }
 
 enum register_status
 regcache_cooked_read_part (struct regcache *regcache, int regnum,
 			   int offset, int len, gdb_byte *buf)
 {
-  struct regcache_descr *descr = regcache->descr;
+  return regcache->cooked_read_part (regnum, offset, len, buf);
+}
+
 
+enum register_status
+regcache::cooked_read_part (int regnum, int offset, int len, gdb_byte *buf)
+{
   gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
-  return regcache_xfer_part (regcache, regnum, offset, len, buf, NULL,
-			     regcache_cooked_read, regcache_cooked_write);
+  return xfer_part (regnum, offset, len, buf, NULL,
+		    regcache_cooked_read, regcache_cooked_write);
 }
 
 void
 regcache_cooked_write_part (struct regcache *regcache, int regnum,
 			    int offset, int len, const gdb_byte *buf)
 {
-  struct regcache_descr *descr = regcache->descr;
+  regcache->cooked_write_part (regnum, offset, len, buf);
+}
 
+void
+regcache::cooked_write_part (int regnum, int offset, int len,
+			     const gdb_byte *buf)
+{
   gdb_assert (regnum >= 0 && regnum < descr->nr_cooked_registers);
-  regcache_xfer_part (regcache, regnum, offset, len, NULL, buf,
-		      regcache_cooked_read, regcache_cooked_write);
+  xfer_part (regnum, offset, len, NULL, buf,
+	     regcache_cooked_read, regcache_cooked_write);
 }
 
 /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE.  */
@@ -1081,20 +1165,26 @@ regcache_cooked_write_part (struct regcache *regcache, int regnum,
 void
 regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
 {
+  gdb_assert (regcache != NULL);
+  regcache->raw_supply (regnum, buf);
+}
+
+void
+regcache::raw_supply (int regnum, const void *buf)
+{
   void *regbuf;
   size_t size;
 
-  gdb_assert (regcache != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
-  gdb_assert (!regcache->readonly_p);
+  gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
+  gdb_assert (!readonly_p);
 
-  regbuf = register_buffer (regcache, regnum);
-  size = regcache->descr->sizeof_register[regnum];
+  regbuf = register_buffer (regnum);
+  size = descr->sizeof_register[regnum];
 
   if (buf)
     {
       memcpy (regbuf, buf, size);
-      regcache->register_status[regnum] = REG_VALID;
+      register_status[regnum] = REG_VALID;
     }
   else
     {
@@ -1102,7 +1192,7 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
 	 in case the register value manages to escape somewhere (due
 	 to a bug, no less).  */
       memset (regbuf, 0, size);
-      regcache->register_status[regnum] = REG_UNAVAILABLE;
+      register_status[regnum] = REG_UNAVAILABLE;
     }
 }
 
@@ -1111,14 +1201,21 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
 void
 regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf)
 {
+  gdb_assert (regcache != NULL && buf != NULL);
+  regcache->raw_collect (regnum, buf);
+}
+
+void
+regcache::raw_collect (int regnum, void *buf) const
+{
   const void *regbuf;
   size_t size;
 
-  gdb_assert (regcache != NULL && buf != NULL);
-  gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
+  gdb_assert (buf != NULL);
+  gdb_assert (regnum >= 0 && regnum < descr->nr_raw_registers);
 
-  regbuf = register_buffer (regcache, regnum);
-  size = regcache->descr->sizeof_register[regnum];
+  regbuf = register_buffer (regnum);
+  size = descr->sizeof_register[regnum];
   memcpy (buf, regbuf, size);
 }
 
@@ -1126,12 +1223,11 @@ regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf)
    set to or from a buffer.  This is the main worker function for
    regcache_supply_regset and regcache_collect_regset.  */
 
-static void
-regcache_transfer_regset (const struct regset *regset,
-			  const struct regcache *regcache,
-			  struct regcache *out_regcache,
-			  int regnum, const void *in_buf,
-			  void *out_buf, size_t size)
+void
+regcache::transfer_regset (const struct regset *regset,
+			   struct regcache *out_regcache,
+			   int regnum, const void *in_buf,
+			   void *out_buf, size_t size) const
 {
   const struct regcache_map_entry *map;
   int offs = 0, count;
@@ -1144,7 +1240,7 @@ regcache_transfer_regset (const struct regset *regset,
       int slot_size = map->size;
 
       if (slot_size == 0 && regno != REGCACHE_MAP_SKIP)
-	slot_size = regcache->descr->sizeof_register[regno];
+	slot_size = descr->sizeof_register[regno];
 
       if (regno == REGCACHE_MAP_SKIP
 	  || (regnum != -1
@@ -1158,12 +1254,11 @@ regcache_transfer_regset (const struct regset *regset,
 	      break;
 
 	    if (out_buf)
-	      regcache_raw_collect (regcache, regno,
-				    (gdb_byte *) out_buf + offs);
+	      raw_collect (regno, (gdb_byte *) out_buf + offs);
 	    else
-	      regcache_raw_supply (out_regcache, regno, in_buf
-				   ? (const gdb_byte *) in_buf + offs
-				   : NULL);
+	      out_regcache->raw_supply (regno, in_buf
+					? (const gdb_byte *) in_buf + offs
+					: NULL);
 	  }
       else
 	{
@@ -1173,12 +1268,11 @@ regcache_transfer_regset (const struct regset *regset,
 	    return;
 
 	  if (out_buf)
-	    regcache_raw_collect (regcache, regnum,
-				  (gdb_byte *) out_buf + offs);
+	    raw_collect (regnum, (gdb_byte *) out_buf + offs);
 	  else
-	    regcache_raw_supply (out_regcache, regnum, in_buf
-				 ? (const gdb_byte *) in_buf + offs
-				 : NULL);
+	    out_regcache->raw_supply (regnum, in_buf
+				      ? (const gdb_byte *) in_buf + offs
+				      : NULL);
 	  return;
 	}
     }
@@ -1193,8 +1287,14 @@ regcache_supply_regset (const struct regset *regset,
 			struct regcache *regcache,
 			int regnum, const void *buf, size_t size)
 {
-  regcache_transfer_regset (regset, regcache, regcache, regnum,
-			    buf, NULL, size);
+  regcache->supply_regset (regset, regnum, buf, size);
+}
+
+void
+regcache::supply_regset (const struct regset *regset,
+			 int regnum, const void *buf, size_t size)
+{
+  transfer_regset (regset, this, regnum, buf, NULL, size);
 }
 
 /* Collect register REGNUM from REGCACHE to BUF, using the register
@@ -1206,8 +1306,14 @@ regcache_collect_regset (const struct regset *regset,
 			 const struct regcache *regcache,
 			 int regnum, void *buf, size_t size)
 {
-  regcache_transfer_regset (regset, regcache, NULL, regnum,
-			    NULL, buf, size);
+  regcache->collect_regset (regset, regnum, buf, size);
+}
+
+void
+regcache::collect_regset (const struct regset *regset,
+			 int regnum, void *buf, size_t size) const
+{
+  transfer_regset (regset, NULL, regnum, NULL, buf, size);
 }
 
 
@@ -1260,10 +1366,9 @@ regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
 }
 
 void
-regcache_debug_print_register (const char *func, struct regcache *regcache,
-			       int regno)
+regcache::debug_print_register (const char *func,  int regno)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = get_arch ();
 
   fprintf_unfiltered (gdb_stdlog, "%s ", func);
   if (regno >= 0 && regno < gdbarch_num_regs (gdbarch)
@@ -1277,7 +1382,7 @@ regcache_debug_print_register (const char *func, struct regcache *regcache,
     {
       enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
       int size = register_size (gdbarch, regno);
-      gdb_byte *buf = register_buffer (regcache, regno);
+      gdb_byte *buf = register_buffer (regno);
 
       fprintf_unfiltered (gdb_stdlog, " = ");
       for (int i = 0; i < size; i++)
@@ -1304,19 +1409,11 @@ reg_flush_command (char *command, int from_tty)
     printf_filtered (_("Register cache flushed.\n"));
 }
 
-enum regcache_dump_what
-{
-  regcache_dump_none, regcache_dump_raw,
-  regcache_dump_cooked, regcache_dump_groups,
-  regcache_dump_remote
-};
-
-static void
-regcache_dump (struct regcache *regcache, struct ui_file *file,
-	       enum regcache_dump_what what_to_dump)
+void
+regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
 {
   struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
-  struct gdbarch *gdbarch = regcache->descr->gdbarch;
+  struct gdbarch *gdbarch = descr->gdbarch;
   int regnum;
   int footnote_nr = 0;
   int footnote_register_size = 0;
@@ -1327,24 +1424,24 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
 
 #if 0
   fprintf_unfiltered (file, "nr_raw_registers %d\n",
-		      regcache->descr->nr_raw_registers);
+		      descr->nr_raw_registers);
   fprintf_unfiltered (file, "nr_cooked_registers %d\n",
-		      regcache->descr->nr_cooked_registers);
+		      descr->nr_cooked_registers);
   fprintf_unfiltered (file, "sizeof_raw_registers %ld\n",
-		      regcache->descr->sizeof_raw_registers);
+		      descr->sizeof_raw_registers);
   fprintf_unfiltered (file, "sizeof_raw_register_status %ld\n",
-		      regcache->descr->sizeof_raw_register_status);
+		      descr->sizeof_raw_register_status);
   fprintf_unfiltered (file, "gdbarch_num_regs %d\n", 
 		      gdbarch_num_regs (gdbarch));
   fprintf_unfiltered (file, "gdbarch_num_pseudo_regs %d\n",
 		      gdbarch_num_pseudo_regs (gdbarch));
 #endif
 
-  gdb_assert (regcache->descr->nr_cooked_registers
+  gdb_assert (descr->nr_cooked_registers
 	      == (gdbarch_num_regs (gdbarch)
 		  + gdbarch_num_pseudo_regs (gdbarch)));
 
-  for (regnum = -1; regnum < regcache->descr->nr_cooked_registers; regnum++)
+  for (regnum = -1; regnum < descr->nr_cooked_registers; regnum++)
     {
       /* Name.  */
       if (regnum < 0)
@@ -1381,12 +1478,12 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
       else
 	{
 	  fprintf_unfiltered (file, " %6ld",
-			      regcache->descr->register_offset[regnum]);
-	  if (register_offset != regcache->descr->register_offset[regnum]
+			      descr->register_offset[regnum]);
+	  if (register_offset != descr->register_offset[regnum]
 	      || (regnum > 0
-		  && (regcache->descr->register_offset[regnum]
-		      != (regcache->descr->register_offset[regnum - 1]
-			  + regcache->descr->sizeof_register[regnum - 1])))
+		  && (descr->register_offset[regnum]
+		      != (descr->register_offset[regnum - 1]
+			  + descr->sizeof_register[regnum - 1])))
 	      )
 	    {
 	      if (!footnote_register_offset)
@@ -1395,16 +1492,15 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
 	    }
 	  else
 	    fprintf_unfiltered (file, "  ");
-	  register_offset = (regcache->descr->register_offset[regnum]
-			     + regcache->descr->sizeof_register[regnum]);
+	  register_offset = (descr->register_offset[regnum]
+			     + descr->sizeof_register[regnum]);
 	}
 
       /* Size.  */
       if (regnum < 0)
 	fprintf_unfiltered (file, " %5s ", "Size");
       else
-	fprintf_unfiltered (file, " %5ld",
-			    regcache->descr->sizeof_register[regnum]);
+	fprintf_unfiltered (file, " %5ld", descr->sizeof_register[regnum]);
 
       /* Type.  */
       {
@@ -1416,7 +1512,7 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
 	  {
 	    static const char blt[] = "builtin_type";
 
-	    t = TYPE_NAME (register_type (regcache->descr->gdbarch, regnum));
+	    t = TYPE_NAME (register_type (get_arch (), regnum));
 	    if (t == NULL)
 	      {
 		char *n;
@@ -1442,17 +1538,17 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
 	{
 	  if (regnum < 0)
 	    fprintf_unfiltered (file, "Raw value");
-	  else if (regnum >= regcache->descr->nr_raw_registers)
+	  else if (regnum >= descr->nr_raw_registers)
 	    fprintf_unfiltered (file, "<cooked>");
-	  else if (regcache_register_status (regcache, regnum) == REG_UNKNOWN)
+	  else if (get_register_status (regnum) == REG_UNKNOWN)
 	    fprintf_unfiltered (file, "<invalid>");
-	  else if (regcache_register_status (regcache, regnum) == REG_UNAVAILABLE)
+	  else if (get_register_status (regnum) == REG_UNAVAILABLE)
 	    fprintf_unfiltered (file, "<unavailable>");
 	  else
 	    {
-	      regcache_raw_read (regcache, regnum, buf);
+	      raw_read (regnum, buf);
 	      print_hex_chars (file, buf,
-			       regcache->descr->sizeof_register[regnum],
+			       descr->sizeof_register[regnum],
 			       gdbarch_byte_order (gdbarch));
 	    }
 	}
@@ -1466,14 +1562,14 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
 	    {
 	      enum register_status status;
 
-	      status = regcache_cooked_read (regcache, regnum, buf);
+	      status = cooked_read (regnum, buf);
 	      if (status == REG_UNKNOWN)
 		fprintf_unfiltered (file, "<invalid>");
 	      else if (status == REG_UNAVAILABLE)
 		fprintf_unfiltered (file, "<unavailable>");
 	      else
 		print_hex_chars (file, buf,
-				 regcache->descr->sizeof_register[regnum],
+				 descr->sizeof_register[regnum],
 				 gdbarch_byte_order (gdbarch));
 	    }
 	}
@@ -1509,11 +1605,11 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
 	    {
 	      fprintf_unfiltered (file, "Rmt Nr  g/G Offset");
 	    }
-	  else if (regnum < regcache->descr->nr_raw_registers)
+	  else if (regnum < descr->nr_raw_registers)
 	    {
 	      int pnum, poffset;
 
-	      if (remote_register_number_and_offset (get_regcache_arch (regcache), regnum,
+	      if (remote_register_number_and_offset (get_arch (), regnum,
 						     &pnum, &poffset))
 		fprintf_unfiltered (file, "%7d %11d", pnum, poffset);
 	    }
@@ -1539,14 +1635,14 @@ static void
 regcache_print (char *args, enum regcache_dump_what what_to_dump)
 {
   if (args == NULL)
-    regcache_dump (get_current_regcache (), gdb_stdout, what_to_dump);
+    get_current_regcache ()->dump (gdb_stdout, what_to_dump);
   else
     {
       stdio_file file;
 
       if (!file.open (args, "w"))
 	perror_with_name (_("maintenance print architecture"));
-      regcache_dump (get_current_regcache (), &file, what_to_dump);
+      get_current_regcache ()->dump (&file, what_to_dump);
     }
 }
 
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 1d60fa7..8794966 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -224,6 +224,162 @@ extern void regcache_save (struct regcache *dst,
 			   regcache_cooked_read_ftype *cooked_read,
 			   void *cooked_read_context);
 
+enum regcache_dump_what
+{
+  regcache_dump_none, regcache_dump_raw,
+  regcache_dump_cooked, regcache_dump_groups,
+  regcache_dump_remote
+};
+
+/* The register cache for storing raw register values.  */
+
+struct regcache
+{
+public:
+  explicit regcache (struct gdbarch *gdbarch, struct address_space *aspace_)
+    : regcache (gdbarch, aspace_, true)
+  {}
+
+  ~regcache ()
+  {
+    xfree (registers);
+    xfree (register_status);
+  }
+
+  struct gdbarch *get_arch () const;
+
+  struct address_space *
+  get_aspace () const
+  {
+    return aspace;
+  }
+
+  void save (regcache_cooked_read_ftype *cooked_read, void *src);
+
+  enum register_status cooked_read (int regnum, gdb_byte *buf);
+  void cooked_write (int regnum, const gdb_byte *buf);
+
+  enum register_status raw_read (int regnum, gdb_byte *buf);
+  void raw_write (int regnum, const gdb_byte *buf);
+
+  enum register_status raw_read_signed (int regnum, LONGEST *val);
+
+  void raw_write_signed (int regnum, LONGEST val);
+
+  enum register_status raw_read_unsigned (int regnum, ULONGEST *val);
+
+  void raw_write_unsigned (int regnum, ULONGEST val);
+
+  struct value *cooked_read_value (int regnum);
+
+  enum register_status cooked_read_signed (int regnum, LONGEST *val);
+
+  void cooked_write_signed (int regnum, LONGEST val);
+
+  enum register_status cooked_read_unsigned (int regnum, ULONGEST *val);
+
+  void cooked_write_unsigned (int regnum, ULONGEST val);
+
+  void raw_update (int regnum);
+
+  void raw_collect (int regnum, void *buf) const;
+
+  void raw_supply (int regnum, const void *buf);
+
+  enum register_status get_register_status (int regnum) const;
+
+  void raw_set_cached_value (int regnum, const gdb_byte *buf);
+
+  void invalidate (int regnum);
+
+  enum register_status raw_read_part (int regnum, int offset, int len,
+				      gdb_byte *buf);
+
+  void raw_write_part (int regnum, int offset, int len, const gdb_byte *buf);
+
+  enum register_status cooked_read_part (int regnum, int offset, int len,
+					 gdb_byte *buf);
+
+  void cooked_write_part (int regnum, int offset, int len,
+			  const gdb_byte *buf);
+
+  void supply_regset (const struct regset *regset,
+		      int regnum, const void *buf, size_t size);
+
+
+  void collect_regset (const struct regset *regset, int regnum,
+		       void *buf, size_t size) const;
+
+  void dump (ui_file *file, enum regcache_dump_what what_to_dump);
+
+  ptid_t get_ptid () const
+  {
+    return ptid;
+  }
+
+  void set_ptid (const ptid_t ptid)
+  {
+    this->ptid = ptid;
+  }
+
+/* Dump the contents of a register from the register cache to the target
+   debug.  */
+  void debug_print_register (const char *func, int regno);
+
+private:
+  explicit regcache (struct gdbarch *gdbarch, struct address_space *aspace_,
+		     bool readonly_p_);
+
+  gdb_byte *register_buffer (int regnum) const;
+
+  void
+  restore (struct regcache *src);
+
+  void cpy_no_passthrough (struct regcache *src);
+
+  enum register_status
+  xfer_part (int regnum, int offset, int len, void *in, const void *out,
+	     enum register_status (*read) (struct regcache *regcache,
+					   int regnum, gdb_byte *buf),
+	     void (*write) (struct regcache *regcache, int regnum,
+			    const gdb_byte *buf));
+
+  void transfer_regset (const struct regset *regset,
+			struct regcache *out_regcache,
+			int regnum, const void *in_buf,
+			void *out_buf, size_t size) const;
+
+  struct regcache_descr *descr;
+
+  /* The address space of this register cache (for registers where it
+     makes sense, like PC or SP).  */
+  struct address_space *aspace;
+
+  /* The register buffers.  A read-only register cache can hold the
+     full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a read/write
+     register cache can only hold [0 .. gdbarch_num_regs).  */
+  gdb_byte *registers;
+  /* Register cache status.  */
+  signed char *register_status;
+  /* Is this a read-only cache?  A read-only cache is used for saving
+     the target's register state (e.g, across an inferior function
+     call or just before forcing a function return).  A read-only
+     cache can only be updated via the methods regcache_dup() and
+     regcache_cpy().  The actual contents are determined by the
+     reggroup_save and reggroup_restore methods.  */
+  bool readonly_p;
+  /* If this is a read-write cache, which thread's registers is
+     it connected to?  */
+  ptid_t ptid;
+
+  friend struct regcache *
+  get_thread_arch_aspace_regcache (ptid_t ptid, struct gdbarch *gdbarch,
+				   struct address_space *aspace);
+
+  friend void
+  regcache_cpy (struct regcache *dst, struct regcache *src);
+};
+
 /* Copy/duplicate the contents of a register cache.  By default, the
    operation is pass-through.  Writes to DST and reads from SRC will
    go through to the target.  See also regcache_cpy_no_passthrough.
@@ -236,10 +392,4 @@ extern void regcache_cpy (struct regcache *dest, struct regcache *src);
 extern void registers_changed (void);
 extern void registers_changed_ptid (ptid_t);
 
-/* Dump the contents of a register from the register cache to the target
-   debug.  */
-extern void regcache_debug_print_register (const char *func,
-					   struct regcache *regcache,
-					   int regno);
-
 #endif /* REGCACHE_H */
diff --git a/gdb/target.c b/gdb/target.c
index 10a5315..e526bcc 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3552,7 +3552,7 @@ target_fetch_registers (struct regcache *regcache, int regno)
 {
   current_target.to_fetch_registers (&current_target, regcache, regno);
   if (targetdebug)
-    regcache_debug_print_register ("target_fetch_registers", regcache, regno);
+    regcache->debug_print_register ("target_fetch_registers", regno);
 }
 
 void
@@ -3564,8 +3564,7 @@ target_store_registers (struct regcache *regcache, int regno)
   current_target.to_store_registers (&current_target, regcache, regno);
   if (targetdebug)
     {
-      regcache_debug_print_register ("target_store_registers", regcache,
-				     regno);
+      regcache->debug_print_register ("target_store_registers", regno);
     }
 }
 
