[21/26] sim: iq2000: invert sim_cpu storage

Message ID 20221105133258.23409-22-vapier@gentoo.org
State Committed
Commit 06f4b7b6d11c87b6420a1afe495d66c55be46913
Headers
Series sim: sim_cpu: invert sim_cpu storage |

Commit Message

Mike Frysinger Nov. 5, 2022, 1:32 p.m. UTC
  The cpu.h change is in generated cgen code, but that has been sent
upstream too, so the next regen should include it automatically.
---
 sim/iq2000/cpu.h      |  2 +-
 sim/iq2000/sim-if.c   |  3 ++-
 sim/iq2000/sim-main.h | 13 ++++---------
 3 files changed, 7 insertions(+), 11 deletions(-)
  

Patch

diff --git a/sim/iq2000/cpu.h b/sim/iq2000/cpu.h
index a204eeb0e350..0a9aa802f117 100644
--- a/sim/iq2000/cpu.h
+++ b/sim/iq2000/cpu.h
@@ -61,7 +61,7 @@  CPU (h_gr[(index)]) = (x);\
 }\
 ;} while (0)
   } hardware;
-#define CPU_CGEN_HW(cpu) (& (cpu)->cpu_data.hardware)
+#define CPU_CGEN_HW(cpu) (& IQ2000_SIM_CPU (cpu)->cpu_data.hardware)
 } IQ2000BF_CPU_DATA;
 
 /* Cover fns for register access.  */
diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c
index 34069f0a044b..1b1b3ac6e615 100644
--- a/sim/iq2000/sim-if.c
+++ b/sim/iq2000/sim-if.c
@@ -70,7 +70,8 @@  sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
-  if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
+  if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct iq2000_sim_cpu))
+      != SIM_RC_OK)
     {
       free_state (sd);
       return 0;
diff --git a/sim/iq2000/sim-main.h b/sim/iq2000/sim-main.h
index bf0608290884..bb927fcf57c5 100644
--- a/sim/iq2000/sim-main.h
+++ b/sim/iq2000/sim-main.h
@@ -4,6 +4,8 @@ 
 #ifndef SIM_MAIN_H
 #define SIM_MAIN_H
 
+#define SIM_HAVE_COMMON_SIM_CPU
+
 /* This is a global setting.  Different cpu families can't mix-n-match -scache
    and -pbb.  However some cpu families may use -simple while others use
    one of -scache/-pbb. ???? */
@@ -22,15 +24,7 @@ 
 #include "sim-base.h"
 #include "cgen-sim.h"
 
-/* The _sim_cpu struct.  */
-
-struct _sim_cpu {
-  /* sim/common cpu base.  */
-  sim_cpu_base base;
-
-  /* Static parts of cgen.  */
-  CGEN_CPU cgen_cpu;
-
+struct iq2000_sim_cpu {
   /* CPU specific parts go here.
      Note that in files that don't need to access these pieces WANT_CPU_FOO
      won't be defined and thus these parts won't appear.  This is ok in the
@@ -42,6 +36,7 @@  struct _sim_cpu {
   IQ2000BF_CPU_DATA cpu_data;
 #endif
 };
+#define IQ2000_SIM_CPU(cpu) ((struct iq2000_sim_cpu *) CPU_ARCH_DATA (cpu))
 
 /* Misc.  */