diff mbox

sim: arm/d10v/h8300/m68hc11/microblaze/mips/mn10300/moxie/sh/v850: convert to common sim_{fetch,store}_register [committed]

Message ID 1451464305-1719-1-git-send-email-vapier@gentoo.org
State Committed
Headers show

Commit Message

Mike Frysinger Dec. 30, 2015, 8:31 a.m. UTC
---
 sim/arm/ChangeLog        |  8 ++++++++
 sim/arm/wrapper.c        | 16 ++++++----------
 sim/d10v/ChangeLog       |  9 +++++++++
 sim/d10v/interp.c        | 17 +++++++++++------
 sim/h8300/ChangeLog      |  8 ++++++++
 sim/h8300/compile.c      | 13 ++++++++-----
 sim/m68hc11/ChangeLog    |  9 +++++++++
 sim/m68hc11/interp.c     | 18 +++++++++---------
 sim/microblaze/ChangeLog |  8 ++++++++
 sim/microblaze/interp.c  | 13 ++++++-------
 sim/mips/ChangeLog       | 11 +++++++++++
 sim/mips/interp.c        | 31 +++++++++++--------------------
 sim/mn10300/ChangeLog    |  9 +++++++++
 sim/mn10300/interp.c     | 19 +++++++++----------
 sim/moxie/ChangeLog      |  8 ++++++++
 sim/moxie/interp.c       | 10 ++++++----
 sim/sh/ChangeLog         |  8 ++++++++
 sim/sh/interp.c          | 10 ++++++----
 sim/v850/ChangeLog       |  9 +++++++++
 sim/v850/interp.c        | 21 ++++++++++-----------
 20 files changed, 169 insertions(+), 86 deletions(-)
diff mbox

Patch

diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog
index 5cfc633..024f52e 100644
--- a/sim/arm/ChangeLog
+++ b/sim/arm/ChangeLog
@@ -1,3 +1,11 @@ 
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* wrapper.c (sim_store_register): Rename to ...
+	(arm_reg_store): ... this.
+	(sim_fetch_register): Rename to ...
+	(arm_reg_fetch): ... this.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+
 2015-12-27  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (SIM_OBJS): Delete sim-hload.o.
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index db96cca..1971268 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -431,11 +431,8 @@  tomem (struct ARMul_State *state,
     }
 }
 
-int
-sim_store_register (SIM_DESC sd ATTRIBUTE_UNUSED,
-		    int rn,
-		    unsigned char *memory,
-		    int length)
+static int
+arm_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   init ();
 
@@ -539,11 +536,8 @@  sim_store_register (SIM_DESC sd ATTRIBUTE_UNUSED,
   return length;
 }
 
-int
-sim_fetch_register (SIM_DESC sd ATTRIBUTE_UNUSED,
-		    int rn,
-		    unsigned char *memory,
-		    int length)
+static int
+arm_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   ARMword regval;
   int len = length;
@@ -870,6 +864,8 @@  sim_open (SIM_OPEN_KIND kind,
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = arm_reg_fetch;
+      CPU_REG_STORE (cpu) = arm_reg_store;
       CPU_PC_FETCH (cpu) = arm_pc_get;
       CPU_PC_STORE (cpu) = arm_pc_set;
     }
diff --git a/sim/d10v/ChangeLog b/sim/d10v/ChangeLog
index 0ff2c2b..6a796bb 100644
--- a/sim/d10v/ChangeLog
+++ b/sim/d10v/ChangeLog
@@ -1,3 +1,12 @@ 
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* wrapper.c (d10v_reg_store, d10v_reg_fetch): Define.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+	(sim_store_register): Rename to ...
+	(d10v_reg_store): ... this.  Rename cpu to sd.
+	(sim_fetch_register): Rename to ...
+	(d10v_reg_fetch): ... this.  Rename cpu to sd.
+
 2015-12-27  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (SIM_OBJS): Delete sim-hload.o.
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index 330fbbc..807c5c2 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -742,6 +742,9 @@  free_state (SIM_DESC sd)
   sim_state_free (sd);
 }
 
+static int d10v_reg_fetch (SIM_CPU *, int, unsigned char *, int);
+static int d10v_reg_store (SIM_CPU *, int, unsigned char *, int);
+
 SIM_DESC
 sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
 {
@@ -806,6 +809,8 @@  sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = d10v_reg_fetch;
+      CPU_REG_STORE (cpu) = d10v_reg_store;
       CPU_PC_FETCH (cpu) = d10v_pc_get;
       CPU_PC_STORE (cpu) = d10v_pc_set;
     }
@@ -1196,10 +1201,10 @@  sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char **argv, char **env)
   return SIM_RC_OK;
 }
 
-int
-sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+d10v_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
-  SIM_CPU *cpu = STATE_CPU (sd, 0);
+  SIM_DESC sd = CPU_STATE (cpu);
   int size;
   switch ((enum sim_d10v_regs) rn)
     {
@@ -1280,10 +1285,10 @@  sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
   return size;
 }
  
-int
-sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+d10v_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
-  SIM_CPU *cpu = STATE_CPU (sd, 0);
+  SIM_DESC sd = CPU_STATE (cpu);
   int size;
   switch ((enum sim_d10v_regs) rn)
     {
diff --git a/sim/h8300/ChangeLog b/sim/h8300/ChangeLog
index b293b29..67d3c66 100644
--- a/sim/h8300/ChangeLog
+++ b/sim/h8300/ChangeLog
@@ -1,5 +1,13 @@ 
 2015-12-30  Mike Frysinger  <vapier@gentoo.org>
 
+	* wrapper.c (sim_store_register): Rename to ...
+	(h8300_reg_store): ... this.  Declare sd.
+	(sim_fetch_register): Rename to ...
+	(h8300_reg_fetch): ... this.  Declare sd.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
 	* compile.c (lreg): Delete.
 	(init_pointers): Delete lreg assignments.
 
diff --git a/sim/h8300/compile.c b/sim/h8300/compile.c
index beb2ab6..4c55a37 100644
--- a/sim/h8300/compile.c
+++ b/sim/h8300/compile.c
@@ -4600,10 +4600,10 @@  sim_read (SIM_DESC sd, SIM_ADDR addr, unsigned char *buffer, int size)
   return size;
 }
 
-
-int
-sim_store_register (SIM_DESC sd, int rn, unsigned char *value, int length)
+static int
+h8300_reg_store (SIM_CPU *cpu, int rn, unsigned char *value, int length)
 {
+  SIM_DESC sd = CPU_STATE (cpu);
   int longval;
   int shortval;
   int intval;
@@ -4665,9 +4665,10 @@  sim_store_register (SIM_DESC sd, int rn, unsigned char *value, int length)
   return length;
 }
 
-int
-sim_fetch_register (SIM_DESC sd, int rn, unsigned char *buf, int length)
+static int
+h8300_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *buf, int length)
 {
+  SIM_DESC sd = CPU_STATE (cpu);
   int v;
   int longreg = 0;
 
@@ -4963,6 +4964,8 @@  sim_open (SIM_OPEN_KIND kind,
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = h8300_reg_fetch;
+      CPU_REG_STORE (cpu) = h8300_reg_store;
       CPU_PC_FETCH (cpu) = h8300_pc_get;
       CPU_PC_STORE (cpu) = h8300_pc_set;
     }
diff --git a/sim/m68hc11/ChangeLog b/sim/m68hc11/ChangeLog
index 9fd9e28..ad83c37 100644
--- a/sim/m68hc11/ChangeLog
+++ b/sim/m68hc11/ChangeLog
@@ -1,3 +1,12 @@ 
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* wrapper.c (m68hc11_reg_store, m68hc11_reg_fetch): Define.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+	(sim_store_register): Rename to ...
+	(m68hc11_reg_store): ... this.  Delete local cpu var.
+	(sim_fetch_register): Rename to ...
+	(m68hc11_reg_fetch): ... this.  Delete local cpu var.
+
 2015-12-27  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (SIM_OBJS): Delete sim-hload.o.
diff --git a/sim/m68hc11/interp.c b/sim/m68hc11/interp.c
index bb93e6c..7fb7005 100644
--- a/sim/m68hc11/interp.c
+++ b/sim/m68hc11/interp.c
@@ -413,6 +413,9 @@  m68hc11_pc_set (sim_cpu *cpu, sim_cia pc)
   cpu_set_pc (cpu, pc);
 }
 
+static int m68hc11_reg_fetch (SIM_CPU *, int, unsigned char *, int);
+static int m68hc11_reg_store (SIM_CPU *, int, unsigned char *, int);
+
 SIM_DESC
 sim_open (SIM_OPEN_KIND kind, host_callback *callback,
           bfd *abfd, char **argv)
@@ -492,6 +495,8 @@  sim_open (SIM_OPEN_KIND kind, host_callback *callback,
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = m68hc11_reg_fetch;
+      CPU_REG_STORE (cpu) = m68hc11_reg_store;
       CPU_PC_FETCH (cpu) = m68hc11_pc_get;
       CPU_PC_STORE (cpu) = m68hc11_pc_set;
     }
@@ -553,14 +558,12 @@  sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
   return sim_prepare_for_program (sd, abfd);
 }
 
-int
-sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+m68hc11_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
-  sim_cpu *cpu;
   uint16 val;
   int size = 2;
 
-  cpu = STATE_CPU (sd, 0);
   switch (rn)
     {
     case A_REGNUM:
@@ -619,13 +622,10 @@  sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
   return size;
 }
 
-int
-sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+m68hc11_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   uint16 val;
-  sim_cpu *cpu;
-
-  cpu = STATE_CPU (sd, 0);
 
   val = *memory++;
   if (length == 2)
diff --git a/sim/microblaze/ChangeLog b/sim/microblaze/ChangeLog
index 9e88371..9346778 100644
--- a/sim/microblaze/ChangeLog
+++ b/sim/microblaze/ChangeLog
@@ -1,3 +1,11 @@ 
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* wrapper.c (sim_store_register): Rename to ...
+	(microblaze_reg_store): ... this.  Delete local cpu var.
+	(sim_fetch_register): Rename to ...
+	(microblaze_reg_fetch): ... this.  Delete local cpu var.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+
 2015-12-27  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (SIM_OBJS): Delete sim-hload.o.
diff --git a/sim/microblaze/interp.c b/sim/microblaze/interp.c
index 3ca5e1f..90dcd6f 100644
--- a/sim/microblaze/interp.c
+++ b/sim/microblaze/interp.c
@@ -304,11 +304,9 @@  sim_engine_run (SIM_DESC sd,
   CPU.cycles += memops; 	/* and memop cycle delays */
 }
 
-int
-sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+microblaze_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
-  SIM_CPU *cpu = STATE_CPU (sd, 0);
-
   if (rn < NUM_REGS + NUM_SPECIAL && rn >= 0)
     {
       if (length == 4)
@@ -328,10 +326,9 @@  sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
     return 0;
 }
 
-int
-sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+microblaze_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
-  SIM_CPU *cpu = STATE_CPU (sd, 0);
   long ival;
 
   if (rn < NUM_REGS + NUM_SPECIAL && rn >= 0)
@@ -447,6 +444,8 @@  sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = microblaze_reg_fetch;
+      CPU_REG_STORE (cpu) = microblaze_reg_store;
       CPU_PC_FETCH (cpu) = microblaze_pc_get;
       CPU_PC_STORE (cpu) = microblaze_pc_set;
 
diff --git a/sim/mips/ChangeLog b/sim/mips/ChangeLog
index 022f960..8b2e23f 100644
--- a/sim/mips/ChangeLog
+++ b/sim/mips/ChangeLog
@@ -1,3 +1,14 @@ 
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* wrapper.c (mips_reg_store, mips_reg_fetch): Define.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+	(sim_store_register): Rename to ...
+	(mips_reg_store): ... this.  Delete local cpu var.
+	Update sim_io_eprintf calls.
+	(sim_fetch_register): Rename to ...
+	(mips_reg_fetch): ... this.  Delete local cpu var.
+	Update sim_io_eprintf calls.
+
 2015-12-27  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (SIM_OBJS): Delete sim-hload.o.
diff --git a/sim/mips/interp.c b/sim/mips/interp.c
index 0ca6f1a..843ba94 100644
--- a/sim/mips/interp.c
+++ b/sim/mips/interp.c
@@ -342,6 +342,9 @@  mips_pc_set (sim_cpu *cpu, sim_cia pc)
   PC = pc;
 }
 
+static int mips_reg_fetch (SIM_CPU *, int, unsigned char *, int);
+static int mips_reg_store (SIM_CPU *, int, unsigned char *, int);
+
 SIM_DESC
 sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
 {
@@ -803,6 +806,8 @@  sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = mips_reg_fetch;
+      CPU_REG_STORE (cpu) = mips_reg_store;
       CPU_PC_FETCH (cpu) = mips_pc_get;
       CPU_PC_STORE (cpu) = mips_pc_set;
     }
@@ -840,15 +845,11 @@  mips_sim_close (SIM_DESC sd, int quitting)
 #endif
 }
 
-int
-sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+mips_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
-  sim_cpu *cpu = STATE_CPU (sd, 0); /* FIXME */
   /* NOTE: gdb (the client) stores registers in target byte order
      while the simulator uses host byte order */
-#ifdef DEBUG
-  sim_io_printf(sd,"sim_store_register(%d,*memory=0x%s);\n",rn,pr_addr(*((SIM_ADDR *)memory)));
-#endif /* DEBUG */
 
   /* Unfortunately this suffers from the same problem as the register
      numbering one. We need to know what the width of each logical
@@ -856,12 +857,10 @@  sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
 
   if (cpu->register_widths[rn] == 0)
     {
-      sim_io_eprintf(sd,"Invalid register width for %d (register store ignored)\n",rn);
+      sim_io_eprintf (CPU_STATE (cpu), "Invalid register width for %d (register store ignored)\n", rn);
       return 0;
     }
 
-
-
   if (rn >= FGR_BASE && rn < FGR_BASE + NR_FGR)
     {
       cpu->fpr_state[rn - FGR_BASE] = fmt_uninterpreted;
@@ -925,26 +924,18 @@  sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
   return 0;
 }
 
-int
-sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+mips_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
-  sim_cpu *cpu = STATE_CPU (sd, 0); /* FIXME */
   /* NOTE: gdb (the client) stores registers in target byte order
      while the simulator uses host byte order */
-#ifdef DEBUG
-#if 0  /* FIXME: doesn't compile */
-  sim_io_printf(sd,"sim_fetch_register(%d=0x%s,mem) : place simulator registers into memory\n",rn,pr_addr(registers[rn]));
-#endif
-#endif /* DEBUG */
 
   if (cpu->register_widths[rn] == 0)
     {
-      sim_io_eprintf (sd, "Invalid register width for %d (register fetch ignored)\n",rn);
+      sim_io_eprintf (CPU_STATE (cpu), "Invalid register width for %d (register fetch ignored)\n", rn);
       return 0;
     }
 
-
-
   /* Any floating point register */
   if (rn >= FGR_BASE && rn < FGR_BASE + NR_FGR)
     {
diff --git a/sim/mn10300/ChangeLog b/sim/mn10300/ChangeLog
index a159aa4..d59a7e8 100644
--- a/sim/mn10300/ChangeLog
+++ b/sim/mn10300/ChangeLog
@@ -1,3 +1,12 @@ 
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* wrapper.c (mn10300_reg_store, mn10300_reg_fetch): Define.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+	(sim_store_register): Rename to ...
+	(mn10300_reg_store): ... this.
+	(sim_fetch_register): Rename to ...
+	(mn10300_reg_fetch): ... this.
+
 2015-12-27  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (MN10300_OBJS): Delete sim-hload.o.
diff --git a/sim/mn10300/interp.c b/sim/mn10300/interp.c
index 4940acc..8550c45 100644
--- a/sim/mn10300/interp.c
+++ b/sim/mn10300/interp.c
@@ -86,6 +86,9 @@  mn10300_pc_set (sim_cpu *cpu, sim_cia pc)
   PC = pc;
 }
 
+static int mn10300_reg_fetch (SIM_CPU *, int, unsigned char *, int);
+static int mn10300_reg_store (SIM_CPU *, int, unsigned char *, int);
+
 /* These default values correspond to expected usage for the chip.  */
 
 SIM_DESC
@@ -308,6 +311,8 @@  sim_open (SIM_OPEN_KIND kind,
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = mn10300_reg_fetch;
+      CPU_REG_STORE (cpu) = mn10300_reg_store;
       CPU_PC_FETCH (cpu) = mn10300_pc_get;
       CPU_PC_STORE (cpu) = mn10300_pc_set;
     }
@@ -338,11 +343,8 @@  sim_create_inferior (SIM_DESC sd,
 /* FIXME These would more efficient to use than load_mem/store_mem,
    but need to be changed to use the memory map.  */
 
-int
-sim_fetch_register (SIM_DESC sd,
-		    int rn,
-		    unsigned char *memory,
-		    int length)
+static int
+mn10300_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   reg_t reg = State.regs[rn];
   uint8 *a = memory;
@@ -353,11 +355,8 @@  sim_fetch_register (SIM_DESC sd,
   return length;
 }
  
-int
-sim_store_register (SIM_DESC sd,
-		    int rn,
-		    unsigned char *memory,
-		    int length)
+static int
+mn10300_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   uint8 *a = memory;
   State.regs[rn] = (a[3] << 24) + (a[2] << 16) + (a[1] << 8) + a[0];
diff --git a/sim/moxie/ChangeLog b/sim/moxie/ChangeLog
index 10477b4..439b69c 100644
--- a/sim/moxie/ChangeLog
+++ b/sim/moxie/ChangeLog
@@ -1,3 +1,11 @@ 
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* wrapper.c (sim_store_register): Rename to ...
+	(moxie_reg_store): ... this.
+	(sim_fetch_register): Rename to ...
+	(moxie_reg_fetch): ... this.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+
 2015-12-27  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (SIM_OBJS): Delete sim-hload.o.
diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c
index b2e6352..3bf6f4d 100644
--- a/sim/moxie/interp.c
+++ b/sim/moxie/interp.c
@@ -1111,8 +1111,8 @@  sim_engine_run (SIM_DESC sd,
     } while (1);
 }
 
-int
-sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+moxie_reg_store (SIM_CPU *scpu, int rn, unsigned char *memory, int length)
 {
   if (rn < NUM_MOXIE_REGS && rn >= 0)
     {
@@ -1131,8 +1131,8 @@  sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
     return 0;
 }
 
-int
-sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+moxie_reg_fetch (SIM_CPU *scpu, int rn, unsigned char *memory, int length)
 {
   if (rn < NUM_MOXIE_REGS && rn >= 0)
     {
@@ -1237,6 +1237,8 @@  sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = moxie_reg_fetch;
+      CPU_REG_STORE (cpu) = moxie_reg_store;
       CPU_PC_FETCH (cpu) = moxie_pc_get;
       CPU_PC_STORE (cpu) = moxie_pc_set;
 
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index 14c4b18..0a0bb56 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,3 +1,11 @@ 
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* wrapper.c (sim_store_register): Rename to ...
+	(sh_reg_store): ... this.
+	(sim_fetch_register): Rename to ...
+	(sh_reg_fetch): ... this.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+
 2015-12-27  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (SIM_OBJS): Delete sim-hload.o.
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index 2092a1a..3abeda6 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -1977,8 +1977,8 @@  enum {
   REGBANK_MACL = 19
 };
 
-int
-sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+sh_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   unsigned val;
 
@@ -2150,8 +2150,8 @@  sim_store_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
   return length;
 }
 
-int
-sim_fetch_register (SIM_DESC sd, int rn, unsigned char *memory, int length)
+static int
+sh_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   int val;
 
@@ -2460,6 +2460,8 @@  sim_open (SIM_OPEN_KIND kind, host_callback *cb, struct bfd *abfd, char **argv)
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = sh_reg_fetch;
+      CPU_REG_STORE (cpu) = sh_reg_store;
       CPU_PC_FETCH (cpu) = sh_pc_get;
       CPU_PC_STORE (cpu) = sh_pc_set;
     }
diff --git a/sim/v850/ChangeLog b/sim/v850/ChangeLog
index e09ad1a..2b66488 100644
--- a/sim/v850/ChangeLog
+++ b/sim/v850/ChangeLog
@@ -1,3 +1,12 @@ 
+2015-12-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* wrapper.c (v850_reg_store, v850_reg_fetch): Define.
+	(sim_open): Call CPU_REG_FETCH/CPU_REG_STORE.
+	(sim_store_register): Rename to ...
+	(v850_reg_store): ... this.
+	(sim_fetch_register): Rename to ...
+	(v850_reg_fetch): ... this.
+
 2015-12-27  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (SIM_OBJS): Delete sim-hload.o.
diff --git a/sim/v850/interp.c b/sim/v850/interp.c
index f055149..422d926 100644
--- a/sim/v850/interp.c
+++ b/sim/v850/interp.c
@@ -188,6 +188,9 @@  v850_pc_set (sim_cpu *cpu, sim_cia pc)
   PC = pc;
 }
 
+static int v850_reg_fetch (SIM_CPU *, int, unsigned char *, int);
+static int v850_reg_store (SIM_CPU *, int, unsigned char *, int);
+
 SIM_DESC
 sim_open (SIM_OPEN_KIND    kind,
 	  host_callback *  cb,
@@ -296,6 +299,8 @@  sim_open (SIM_OPEN_KIND    kind,
     {
       SIM_CPU *cpu = STATE_CPU (sd, i);
 
+      CPU_REG_FETCH (cpu) = v850_reg_fetch;
+      CPU_REG_STORE (cpu) = v850_reg_store;
       CPU_PC_FETCH (cpu) = v850_pc_get;
       CPU_PC_STORE (cpu) = v850_pc_set;
     }
@@ -315,21 +320,15 @@  sim_create_inferior (SIM_DESC      sd,
   return SIM_RC_OK;
 }
 
-int
-sim_fetch_register (SIM_DESC         sd,
-		    int              rn,
-		    unsigned char *  memory,
-		    int              length)
+static int
+v850_reg_fetch (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   *(unsigned32*)memory = H2T_4 (State.regs[rn]);
   return -1;
 }
- 
-int
-sim_store_register (SIM_DESC        sd,
-		    int             rn,
-		    unsigned char * memory,
-		    int             length)
+
+static int
+v850_reg_store (SIM_CPU *cpu, int rn, unsigned char *memory, int length)
 {
   State.regs[rn] = T2H_4 (*(unsigned32 *) memory);
   return length;