]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: cris/frv/h8300/iq2000/lm32/m32r/sh64: standardize cpu state
authorMike Frysinger <vapier@gentoo.org>
Wed, 15 Apr 2015 05:22:34 +0000 (01:22 -0400)
committerMike Frysinger <vapier@gentoo.org>
Wed, 15 Apr 2015 05:25:32 +0000 (01:25 -0400)
This sets up the sim_state structure and the cpu member to match what we
do in most other sims, and what the common code suggests.  This is a step
to unifying on the sim-cpu.o object.

15 files changed:
sim/cris/ChangeLog
sim/cris/sim-main.h
sim/frv/ChangeLog
sim/frv/sim-main.h
sim/h8300/ChangeLog
sim/h8300/compile.c
sim/h8300/sim-main.h
sim/iq2000/ChangeLog
sim/iq2000/sim-main.h
sim/lm32/ChangeLog
sim/lm32/sim-main.h
sim/m32r/ChangeLog
sim/m32r/sim-main.h
sim/sh64/ChangeLog
sim/sh64/sim-main.h

index b69e20fc63a34fbadbea73555eedeb3b1cedebb9..b1ac59136fc912f49f9313ba3c1cba02b4db4483 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-15  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-main.h (struct sim_state): Change cpu to an array of pointers.
+       (STATE_CPU): Handle WITH_SMP.
+
 2015-04-13  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index 18c536ff6908cc2dbc33f84069e9eefd7d5a89e2..5ae292e998740a46dbeb220e0a55ef12f7b74460 100644 (file)
@@ -225,8 +225,12 @@ struct _sim_cpu {
 /* The sim_state struct.  */
 
 struct sim_state {
-  sim_cpu *cpu;
-#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu)
+  sim_cpu *cpu[MAX_NR_PROCESSORS];
+#if (WITH_SMP)
+#define STATE_CPU(sd,n) ((sd)->cpu[n])
+#else
+#define STATE_CPU(sd,n) ((sd)->cpu[0])
+#endif
 
   CGEN_STATE cgen_state;
 
index 9580c5649ca6726199f81fe6b9c321e6957e6549..8e7e995b4b4b0a63b378d65241a8f0dc189bada7 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-15  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-main.h (struct sim_state): Change cpu to an array of pointers.
+       (STATE_CPU): Handle WITH_SMP.
+
 2015-04-13  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index 7528f6acea320a9ac8f2c9a36d5c0f15c8ab170c..e7dc1a2d9159ff9cd6390becf0da171a7e3307eb 100644 (file)
@@ -118,8 +118,12 @@ struct _sim_cpu {
 /* The sim_state struct.  */
 
 struct sim_state {
-  sim_cpu *cpu;
-#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu)
+  sim_cpu *cpu[MAX_NR_PROCESSORS];
+#if (WITH_SMP)
+#define STATE_CPU(sd,n) ((sd)->cpu[n])
+#else
+#define STATE_CPU(sd,n) ((sd)->cpu[0])
+#endif
 
   CGEN_STATE cgen_state;
 
index 215a182fbc2dc191e5abe90f99497ffc316739df..1740b3db50e72219c002b9e8e894778f72e4b4af 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-15  Mike Frysinger  <vapier@gentoo.org>
+
+       * compile.c: Include sim-options.h.
+       (sim_open): Call sim_cpu_alloc_all instead of sim_cpu_alloc.
+       * sim-main.h (struct sim_state): Change cpu to an array of pointers.
+       (STATE_CPU): Handle WITH_SMP.
+
 2015-04-13  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index 2574168e33bc7e6880cef92b4cf9669c50e0f193..e14c3ab625530f909d91447ccc76f8165ffb0113 100644 (file)
@@ -34,6 +34,7 @@
 #include "gdb/sim-h8300.h"
 #include "sys/stat.h"
 #include "sys/types.h"
+#include "sim-options.h"
 
 #ifndef SIGTRAP
 # define SIGTRAP 5
@@ -4886,7 +4887,14 @@ sim_open (SIM_OPEN_KIND kind,
   sim_cpu *cpu;
 
   sd = sim_state_alloc (kind, callback);
-  sd->cpu = sim_cpu_alloc (sd, 0);
+
+  /* The cpu data is kept in a separately allocated chunk of memory.  */
+  if (sim_cpu_alloc_all (sd, 1, /*cgen_cpu_max_extra_bytes ()*/0) != SIM_RC_OK)
+    {
+      free_state (sd);
+      return 0;
+    }
+
   cpu = STATE_CPU (sd, 0);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
   sim_state_initialize (sd, cpu);
index 964388ac56055cffd3c99e3a7d199c2ee25230ea..7126fa35c005988bcc5f61f1cb4f513d6f4927f1 100644 (file)
@@ -138,7 +138,7 @@ struct _sim_cpu {
 
 /* The sim_state struct.  */
 struct sim_state {
-  struct _sim_cpu *cpu;
+  sim_cpu *cpu[MAX_NR_PROCESSORS];
   unsigned int sim_cache_size;
   decoded_inst *sim_cache;
   unsigned short *cache_idx;
@@ -155,7 +155,11 @@ struct sim_state {
 
 #define CIA_GET(CPU)           (cpu_get_pc (CPU))
 #define CIA_SET(CPU, VAL)      (cpu_set_pc ((CPU), (VAL)))
-#define STATE_CPU(SD, N)       ((SD)->cpu)     /* Single Processor.  */
+#if (WITH_SMP)
+#define STATE_CPU(sd,n) ((sd)->cpu[n])
+#else
+#define STATE_CPU(sd,n) ((sd)->cpu[0])
+#endif
 #define cpu_set_pc(CPU, VAL)   (((CPU)->pc)  = (VAL))
 #define cpu_get_pc(CPU)                (((CPU)->pc))
 
index 9da17e5908489880ecfe22a708e5fd7b1ab1bd7d..b590cb043a88c5394327f79ae19fea6b7a834edb 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-15  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-main.h (struct sim_state): Change cpu to an array of pointers.
+       (STATE_CPU): Handle WITH_SMP.
+
 2015-04-13  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index d6cb7825e1263954571af8167a9c9107412985b2..623c0a6e575e5fcd7126449c046fc7f0f61e17b8 100644 (file)
@@ -57,8 +57,12 @@ struct _sim_cpu {
 /* The sim_state struct.  */
 
 struct sim_state {
-  sim_cpu *cpu;
-#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu)
+  sim_cpu *cpu[MAX_NR_PROCESSORS];
+#if (WITH_SMP)
+#define STATE_CPU(sd,n) ((sd)->cpu[n])
+#else
+#define STATE_CPU(sd,n) ((sd)->cpu[0])
+#endif
 
   CGEN_STATE cgen_state;
 
index fdb204bb05b8e100ab7f504dd8975a7d6ae2867f..94a1ccddbf432d59c05c0bd30ebfa37d27572474 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-15  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-main.h (struct sim_state): Change cpu to an array of pointers.
+       (STATE_CPU): Handle WITH_SMP.
+
 2015-04-13  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index a4e44237377fef17d9da14f1d773c2f525438625..d98560753d2c7b24ff3670314f1b23d3e155fb0f 100644 (file)
@@ -83,8 +83,12 @@ struct _sim_cpu
 
 struct sim_state
 {
-  sim_cpu *cpu;
-#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu)
+  sim_cpu *cpu[MAX_NR_PROCESSORS];
+#if (WITH_SMP)
+#define STATE_CPU(sd,n) ((sd)->cpu[n])
+#else
+#define STATE_CPU(sd,n) ((sd)->cpu[0])
+#endif
 
   CGEN_STATE cgen_state;
 
index 2dcd3a0787cc4998a1bfc0588d0cd3f8393865eb..c8a285cfeafe52f046452355328907ddc20addf2 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-15  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-main.h (struct sim_state): Change cpu to an array of pointers.
+       (STATE_CPU): Handle WITH_SMP.
+
 2015-04-13  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index 2cbb40b99b499d21128a0f1ba062bb9ff60113c3..96c1ec1747d0e50a1a3db7975e016e7ea255cfbf 100644 (file)
@@ -68,8 +68,12 @@ struct _sim_cpu {
 /* The sim_state struct.  */
 
 struct sim_state {
-  sim_cpu *cpu;
-#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu)
+  sim_cpu *cpu[MAX_NR_PROCESSORS];
+#if (WITH_SMP)
+#define STATE_CPU(sd,n) ((sd)->cpu[n])
+#else
+#define STATE_CPU(sd,n) ((sd)->cpu[0])
+#endif
 
   CGEN_STATE cgen_state;
 
index 574fbb10880a5d1e01b700c7f182c6632493621c..5bbc7a3f511495e4dc1404616f632b090376ff39 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-15  Mike Frysinger  <vapier@gentoo.org>
+
+       * sim-main.h (struct sim_state): Change cpu to an array of pointers.
+       (STATE_CPU): Handle WITH_SMP.
+
 2015-04-13  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index e7cbe99217a3f5e3cb2ab783aa07cdc2b1a07114..5ae4309916aff326057e873336af2a563aa84bbd 100644 (file)
@@ -53,8 +53,12 @@ struct _sim_cpu {
 /* The sim_state struct.  */
 
 struct sim_state {
-  sim_cpu *cpu;
-#define STATE_CPU(sd, n) (/*&*/ (sd)->cpu)
+  sim_cpu *cpu[MAX_NR_PROCESSORS];
+#if (WITH_SMP)
+#define STATE_CPU(sd,n) ((sd)->cpu[n])
+#else
+#define STATE_CPU(sd,n) ((sd)->cpu[0])
+#endif
 
   CGEN_STATE cgen_state;