[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gdb-cvs
Subject:    [binutils-gdb] sim: namespace sim_machs
From:       Michael Frysinger via Gdb-cvs <gdb-cvs () sourceware ! org>
Date:       2021-06-30 6:04:49
Message-ID: 20210630060449.668063858D29 () sourceware ! org
[Download RAW message or body]

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c636da093f335cd57e7fca0fc25ae9f9e849264

commit 1c636da093f335cd57e7fca0fc25ae9f9e849264
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Mon Jun 28 21:42:56 2021 -0400

    sim: namespace sim_machs
    
    We want to do a single build with all arches in one binary which means
    we need to namespace sim_machs on a per-arch basis.  Move it from a
    global variable to the sim description structure so it can be setup at
    runtime.
    
    Changing the SIM_MODEL->num from an enum to an int is unfortunate, but
    we specifically don't want to maintain a centralized list anymore, and
    this was never used directly in common code, just passed to per-arch
    callbacks.

Diff:
---
 sim/bfin/ChangeLog      |  7 +++++++
 sim/bfin/interp.c       |  1 +
 sim/bfin/machs.c        |  2 +-
 sim/bfin/machs.h        |  1 +
 sim/bpf/ChangeLog       |  7 +++++++
 sim/bpf/arch.c          |  2 +-
 sim/bpf/sim-if.c        |  5 +++++
 sim/common/ChangeLog    | 24 ++++++++++++++++++++++++
 sim/common/cgen-defs.h  |  2 +-
 sim/common/cgen-utils.c | 10 ++++++----
 sim/common/sim-base.h   |  4 ++++
 sim/common/sim-cpu.c    |  2 +-
 sim/common/sim-model.c  | 46 +++++++++++++++++++++++++++-------------------
 sim/common/sim-model.h  | 16 ++++------------
 sim/cris/ChangeLog      |  7 +++++++
 sim/cris/arch.c         |  2 +-
 sim/cris/sim-if.c       |  3 +++
 sim/frv/ChangeLog       |  7 +++++++
 sim/frv/arch.c          |  2 +-
 sim/frv/sim-if.c        |  3 +++
 sim/iq2000/ChangeLog    |  7 +++++++
 sim/iq2000/arch.c       |  2 +-
 sim/iq2000/sim-if.c     |  3 +++
 sim/lm32/ChangeLog      |  7 +++++++
 sim/lm32/arch.c         |  2 +-
 sim/lm32/sim-if.c       |  3 +++
 sim/m32r/ChangeLog      |  7 +++++++
 sim/m32r/arch.c         |  2 +-
 sim/m32r/sim-if.c       |  3 +++
 sim/or1k/ChangeLog      |  7 +++++++
 sim/or1k/arch.c         |  2 +-
 sim/or1k/sim-if.c       |  3 +++
 sim/riscv/ChangeLog     |  7 +++++++
 sim/riscv/interp.c      |  3 +++
 sim/riscv/machs.c       |  2 +-
 35 files changed, 167 insertions(+), 46 deletions(-)

diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog
index a26a35a136c..6b0000ac7cf 100644
--- a/sim/bfin/ChangeLog
+++ b/sim/bfin/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* interp.c (sim_open): Set STATE_MACHS.
+	* machs.c (sim_machs): Rename to ...
+	(bfin_sim_machs): ... this.
+	* machs.h (bfin_sim_machs): New decl.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* machs.c (sim_machs): Mark const.
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index ddd0e7a372e..dcc7a132d76 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -703,6 +703,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
 				       sizeof (struct bfin_board_data));
 
   /* Set default options before parsing user options.  */
+  STATE_MACHS (sd) = bfin_sim_machs;
   current_alignment = STRICT_ALIGNMENT;
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
diff --git a/sim/bfin/machs.c b/sim/bfin/machs.c
index ff49bb7c3bb..a6f7033a1ae 100644
--- a/sim/bfin/machs.c
+++ b/sim/bfin/machs.c
@@ -1962,7 +1962,7 @@ static const SIM_MACH bfin_mach =
   bfin_prepare_run
 };
 
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const bfin_sim_machs[] =
 {
   & bfin_mach,
   NULL
diff --git a/sim/bfin/machs.h b/sim/bfin/machs.h
index 105f50c160b..55c260a15b5 100644
--- a/sim/bfin/machs.h
+++ b/sim/bfin/machs.h
@@ -32,6 +32,7 @@ struct bfin_board_data {
 void bfin_model_cpu_init (SIM_DESC, SIM_CPU *);
 bu32 bfin_model_get_chipid (SIM_DESC);
 bu32 bfin_model_get_dspid (SIM_DESC);
+extern const SIM_MACH * const bfin_sim_machs[];
 
 #define BFIN_COREMMR_CEC_BASE		0xFFE02100
 #define BFIN_COREMMR_CEC_SIZE		(4 * 5)
diff --git a/sim/bpf/ChangeLog b/sim/bpf/ChangeLog
index 2d847bb0278..959c63f97a9 100644
--- a/sim/bpf/ChangeLog
+++ b/sim/bpf/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* arch.c (sim_machs): Rename to ...
+	(bpf_sim_machs): ... this.
+	* sim-if.c (bpf_sim_machs): New decl.
+	(sim_open): Set STATE_MACH.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* arch.c (sim_machs): Mark const.
diff --git a/sim/bpf/arch.c b/sim/bpf/arch.c
index 8ceaa34cef8..c9f98c5962d 100644
--- a/sim/bpf/arch.c
+++ b/sim/bpf/arch.c
@@ -25,7 +25,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const bpf_sim_machs[] =
 {
 #ifdef HAVE_CPU_BPFBF
   & bpf_mach,
diff --git a/sim/bpf/sim-if.c b/sim/bpf/sim-if.c
index 436cc86f415..150f5cd6786 100644
--- a/sim/bpf/sim-if.c
+++ b/sim/bpf/sim-if.c
@@ -111,6 +111,8 @@ bpf_free_state (SIM_DESC sd)
   sim_state_free (sd);
 }
 
+extern const SIM_MACH * const bpf_sim_machs[];
+
 /* Create an instance of the simulator.  */
 
 SIM_DESC
@@ -125,6 +127,9 @@ sim_open (SIM_OPEN_KIND kind,
 
   SIM_DESC sd = sim_state_alloc (kind, callback);
 
+  /* Set default options before parsing user options.  */
+  STATE_MACHS (sd) = bpf_sim_machs;
+
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     goto error;
 
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 5d86dcbe7d0..63e7f3be345 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,27 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* cgen-defs.h (cgen_cpu_max_extra_bytes): Add SIM_DESC arg.
+	* cgen-utils.c (cgen_cpu_max_extra_bytes): Likewise.  Change sim_machs
+	to STATE_MACHS.
+	* sim-base.h (struct sim_state): Add machs.
+	(STATE_MACHS): New define.
+	* sim-cpu.c (sim_cpu_alloc): Pass sd to cgen_cpu_max_extra_bytes.
+	* sim-model.c (model_option_handler): Pass sd to sim_model_lookup.
+	Change sim_machs to STATE_MACHS.
+	(sim_model_lookup): Add SIM_DESC arg.  Change sim_machs to
+	STATE_MACHS.
+	(sim_mach_lookup): Likewiwse.
+	(sim_mach_lookup_bfd_name): Likewise.
+	(sim_model_init): Pass sd to sim_model_lookup and
+	sim_mach_lookup_bfd_name.
+	(sim_machs): Delete.
+	* sim-model.h (enum mach_attr): Delete.
+	(SIM_MODEL): Change num to int.
+	(sim_machs): Delete.
+	(sim_model_lookup): Add SIM_DESC arg.
+	(sim_mach_lookup): Likewise.
+	(sim_mach_lookup_bfd_name): Likewise.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* Make-common.in (Makefile): Replace $(arch) and pass more files to
diff --git a/sim/common/cgen-defs.h b/sim/common/cgen-defs.h
index 520c29cb3b9..b6ed2ee3a20 100644
--- a/sim/common/cgen-defs.h
+++ b/sim/common/cgen-defs.h
@@ -146,7 +146,7 @@ extern CPU_INSN_NAME_FN cgen_insn_name;
 /* Return the maximum number of extra bytes required for a sim_cpu struct.  */
 /* ??? Ok, yes, this is less pretty than it should be.  Give me a better
    language [or suggest a better way].  */
-extern int cgen_cpu_max_extra_bytes (void);
+extern int cgen_cpu_max_extra_bytes (SIM_DESC);
 
 /* Target supplied routine to process an invalid instruction.  */
 extern SEM_PC sim_engine_invalid_insn (SIM_CPU *, IADDR, SEM_PC);
diff --git a/sim/common/cgen-utils.c b/sim/common/cgen-utils.c
index 8c0856c795b..d9c3ea9aa80 100644
--- a/sim/common/cgen-utils.c
+++ b/sim/common/cgen-utils.c
@@ -101,14 +101,16 @@ cgen_insn_name (SIM_CPU *cpu, int i)
 /* Return the maximum number of extra bytes required for a SIM_CPU struct.  */
 
 int
-cgen_cpu_max_extra_bytes (void)
+cgen_cpu_max_extra_bytes (SIM_DESC sd)
 {
-  int i;
+  const SIM_MACH * const *machp;
   int extra = 0;
 
-  for (i = 0; sim_machs[i] != 0; ++i)
+  SIM_ASSERT (STATE_MACHS (sd) != NULL);
+
+  for (machp = STATE_MACHS (sd); *machp != NULL; ++machp)
     {
-      int size = IMP_PROPS_SIM_CPU_SIZE (MACH_IMP_PROPS (sim_machs[i]));
+      int size = IMP_PROPS_SIM_CPU_SIZE (MACH_IMP_PROPS (*machp));
       if (size > extra)
 	extra = size;
     }
diff --git a/sim/common/sim-base.h b/sim/common/sim-base.h
index 054b2ba0c6e..8eae988eb50 100644
--- a/sim/common/sim-base.h
+++ b/sim/common/sim-base.h
@@ -143,6 +143,10 @@ struct sim_state {
   const char *target;
 #define STATE_TARGET(sd) ((sd)->target)
 
+  /* List of machs available.  */
+  const SIM_MACH * const *machs;
+#define STATE_MACHS(sd) ((sd)->machs)
+
   /* In standalone simulator, this is the program's arguments passed
      on the command line.  */
   char **prog_argv;
diff --git a/sim/common/sim-cpu.c b/sim/common/sim-cpu.c
index 587a3e8c9e1..bde3e617ce3 100644
--- a/sim/common/sim-cpu.c
+++ b/sim/common/sim-cpu.c
@@ -48,7 +48,7 @@ sim_cpu_alloc (SIM_DESC sd)
   int extra_bytes = 0;
 
 #ifdef CGEN_ARCH
-  extra_bytes += cgen_cpu_max_extra_bytes ();
+  extra_bytes += cgen_cpu_max_extra_bytes (sd);
 #endif
 
   return zalloc (sizeof (sim_cpu) + extra_bytes);
diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c
index bfdb3c24bc8..4c5e463f1a0 100644
--- a/sim/common/sim-model.c
+++ b/sim/common/sim-model.c
@@ -62,7 +62,7 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
     {
     case OPTION_MODEL :
       {
-	const SIM_MODEL *model = sim_model_lookup (arg);
+	const SIM_MODEL *model = sim_model_lookup (sd, arg);
 	if (! model)
 	  {
 	    sim_io_eprintf (sd, "unknown model `%s'\n", arg);
@@ -76,7 +76,14 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
       {
 	const SIM_MACH * const *machp;
 	const SIM_MODEL *model;
-	for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+
+	if (STATE_MACHS (sd) == NULL)
+	  {
+	    sim_io_printf (sd, "This target does not support any models\n");
+	    return SIM_RC_FAIL;
+	  }
+
+	for (machp = STATE_MACHS(sd); *machp != NULL; ++machp)
 	  {
 	    sim_io_printf (sd, "Models for architecture `%s':\n",
 			   MACH_NAME (*machp));
@@ -138,12 +145,15 @@ sim_model_set (SIM_DESC sd, sim_cpu *cpu, const SIM_MODEL *model)
    Result is pointer to MODEL entry or NULL if not found.  */
 
 const SIM_MODEL *
-sim_model_lookup (const char *name)
+sim_model_lookup (SIM_DESC sd, const char *name)
 {
   const SIM_MACH * const *machp;
   const SIM_MODEL *model;
 
-  for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+  if (STATE_MACHS (sd) == NULL)
+    return NULL;
+
+  for (machp = STATE_MACHS (sd); *machp != NULL; ++machp)
     {
       for (model = MACH_MODELS (*machp); MODEL_NAME (model) != NULL; ++model)
 	{
@@ -158,11 +168,14 @@ sim_model_lookup (const char *name)
    Result is pointer to MACH entry or NULL if not found.  */
 
 const SIM_MACH *
-sim_mach_lookup (const char *name)
+sim_mach_lookup (SIM_DESC sd, const char *name)
 {
   const SIM_MACH * const *machp;
 
-  for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+  if (STATE_MACHS (sd) == NULL)
+    return NULL;
+
+  for (machp = STATE_MACHS (sd); *machp != NULL; ++machp)
     {
       if (strcmp (MACH_NAME (*machp), name) == 0)
 	return *machp;
@@ -174,11 +187,14 @@ sim_mach_lookup (const char *name)
    Result is pointer to MACH entry or NULL if not found.  */
 
 const SIM_MACH *
-sim_mach_lookup_bfd_name (const char *name)
+sim_mach_lookup_bfd_name (SIM_DESC sd, const char *name)
 {
   const SIM_MACH * const *machp;
 
-  for (machp = & sim_machs[0]; *machp != NULL; ++machp)
+  if (STATE_MACHS (sd) == NULL)
+    return NULL;
+
+  for (machp = STATE_MACHS (sd); *machp != NULL; ++machp)
     {
       if (strcmp (MACH_BFD_NAME (*machp), name) == 0)
 	return *machp;
@@ -209,7 +225,7 @@ sim_model_init (SIM_DESC sd)
       && ! CPU_MACH (cpu))
     {
       /* Set the default model.  */
-      const SIM_MODEL *model = sim_model_lookup (WITH_DEFAULT_MODEL);
+      const SIM_MODEL *model = sim_model_lookup (sd, WITH_DEFAULT_MODEL);
       SIM_ASSERT (model != NULL);
       sim_model_set (sd, NULL, model);
     }
@@ -230,7 +246,8 @@ sim_model_init (SIM_DESC sd)
     {
       /* Use the default model for the selected machine.
 	 The default model is the first one in the list.  */
-      const SIM_MACH *mach = sim_mach_lookup_bfd_name (STATE_ARCHITECTURE (sd)->printable_name);
+      const SIM_MACH *mach =
+	sim_mach_lookup_bfd_name (sd, STATE_ARCHITECTURE (sd)->printable_name);
 
       if (mach == NULL)
 	{
@@ -247,12 +264,3 @@ sim_model_init (SIM_DESC sd)
 
   return SIM_RC_OK;
 }
-
-#if !WITH_MODEL_P
-/* Set up basic model support.  This is a stub for ports that do not define
-   models.  See sim-model.h for more details.  */
-const SIM_MACH * const sim_machs[] =
-{
-  NULL
-};
-#endif
diff --git a/sim/common/sim-model.h b/sim/common/sim-model.h
index d6edf649d6e..e735feb4b9a 100644
--- a/sim/common/sim-model.h
+++ b/sim/common/sim-model.h
@@ -48,8 +48,6 @@ typedef struct {
 #endif
 
 #ifndef WITH_DEFAULT_MODEL
-/* Just a stub for ports that do not define models.  */
-enum mach_attr { _MACH_NONE };
 # define WITH_DEFAULT_MODEL NULL
 # define WITH_MODEL_P 0
 #else
@@ -92,7 +90,7 @@ typedef struct {
   /* This is the argument to bfd_scan_arch.  */
   const char *bfd_name;
 #define MACH_BFD_NAME(m) ((m)->bfd_name)
-  enum mach_attr num;
+  int num;
 #define MACH_NUM(m) ((m)->num)
 
   int word_bitsize;
@@ -136,19 +134,13 @@ typedef struct model {
 #define MODEL_INIT(m) ((m)->init)
 } SIM_MODEL;
 
-/* Tables of supported machines.  */
-/* ??? In a simulator of multiple architectures, will need multiple copies of
-   this.  Have an `archs' array that contains a pointer to the machs array
-   for each (which in turn has a pointer to the models array for each).  */
-extern const SIM_MACH * const sim_machs[];
-
 /* Model module handlers.  */
 extern MODULE_INSTALL_FN sim_model_install;
 
 /* Support routines.  */
 extern void sim_model_set (SIM_DESC sd_, sim_cpu *cpu_, const SIM_MODEL *model_);
-extern const SIM_MODEL *sim_model_lookup (const char *name_);
-extern const SIM_MACH *sim_mach_lookup (const char *name_);
-extern const SIM_MACH *sim_mach_lookup_bfd_name (const char *bfd_name_);
+extern const SIM_MODEL *sim_model_lookup (SIM_DESC, const char *name_);
+extern const SIM_MACH *sim_mach_lookup (SIM_DESC, const char *name_);
+extern const SIM_MACH *sim_mach_lookup_bfd_name (SIM_DESC, const char *bfd_name_);
 
 #endif /* SIM_MODEL_H */
diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog
index bb67da67cea..292085038d5 100644
--- a/sim/cris/ChangeLog
+++ b/sim/cris/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* arch.c (sim_machs): Rename to ...
+	(cris_sim_machs): ... this.
+	* sim-if.c (cris_sim_machs): New decl.
+	(sim_open): Set STATE_MACH.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* Makefile.in (stamp-v10fcpu): Do not insert cgen-ops.h include.
diff --git a/sim/cris/arch.c b/sim/cris/arch.c
index 1635ef6a955..cd83edeaaed 100644
--- a/sim/cris/arch.c
+++ b/sim/cris/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const cris_sim_machs[] =
 {
 #ifdef HAVE_CPU_CRISV10F
   & crisv10_mach,
diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c
index 99249393521..37a1d5b558a 100644
--- a/sim/cris/sim-if.c
+++ b/sim/cris/sim-if.c
@@ -608,6 +608,8 @@ cris_handle_interpreter (SIM_DESC sd, struct bfd *abfd)
   return ok;
 }
 
+extern const SIM_MACH * const cris_sim_machs[];
+
 /* Create an instance of the simulator.  */
 
 SIM_DESC
@@ -656,6 +658,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   bfd_byte sp_init[4] = {0, 0, 0, 0};
 
   /* Set default options before parsing user options.  */
+  STATE_MACHS (sd) = cris_sim_machs;
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
diff --git a/sim/frv/ChangeLog b/sim/frv/ChangeLog
index 78208fbf154..7cc35c5f74d 100644
--- a/sim/frv/ChangeLog
+++ b/sim/frv/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* arch.c (sim_machs): Rename to ...
+	(frv_sim_machs): ... this.
+	* sim-if.c (frv_sim_machs): New decl.
+	(sim_open): Set STATE_MACH.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* arch.c (sim_machs): Mark const.
diff --git a/sim/frv/arch.c b/sim/frv/arch.c
index f58ed116816..db18ec4d727 100644
--- a/sim/frv/arch.c
+++ b/sim/frv/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const frv_sim_machs[] =
 {
 #ifdef HAVE_CPU_FRVBF
   & frv_mach,
diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c
index 530a8dd0428..82f4bd845f5 100644
--- a/sim/frv/sim-if.c
+++ b/sim/frv/sim-if.c
@@ -42,6 +42,8 @@ free_state (SIM_DESC sd)
   sim_state_free (sd);
 }
 
+extern const SIM_MACH * const frv_sim_machs[];
+
 /* Create an instance of the simulator.  */
 
 SIM_DESC
@@ -54,6 +56,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, bfd *abfd,
   SIM_DESC sd = sim_state_alloc (kind, callback);
 
   /* Set default options before parsing user options.  */
+  STATE_MACHS (sd) = frv_sim_machs;
   current_alignment = STRICT_ALIGNMENT;
   current_target_byte_order = BFD_ENDIAN_BIG;
 
diff --git a/sim/iq2000/ChangeLog b/sim/iq2000/ChangeLog
index cc5d594e0a9..130c6bf726c 100644
--- a/sim/iq2000/ChangeLog
+++ b/sim/iq2000/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* arch.c (sim_machs): Rename to ...
+	(iq2000_sim_machs): ... this.
+	* sim-if.c (iq2000_sim_machs): New decl.
+	(sim_open): Set STATE_MACH.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* arch.c (sim_machs): Mark const.
diff --git a/sim/iq2000/arch.c b/sim/iq2000/arch.c
index 22dc565b1bc..523dfe1bc00 100644
--- a/sim/iq2000/arch.c
+++ b/sim/iq2000/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const iq2000_sim_machs[] =
 {
 #ifdef HAVE_CPU_IQ2000BF
   & iq2000_mach,
diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c
index 1129cee9145..6df4b944300 100644
--- a/sim/iq2000/sim-if.c
+++ b/sim/iq2000/sim-if.c
@@ -50,6 +50,8 @@ free_state (SIM_DESC sd)
   sim_state_free (sd);
 }
 
+extern const SIM_MACH * const iq2000_sim_machs[];
+
 /* Create an instance of the simulator.  */
 
 SIM_DESC
@@ -61,6 +63,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   SIM_DESC sd = sim_state_alloc (kind, callback);
 
   /* Set default options before parsing user options.  */
+  STATE_MACHS (sd) = iq2000_sim_machs;
   current_alignment = STRICT_ALIGNMENT;
   current_target_byte_order = BFD_ENDIAN_BIG;
 
diff --git a/sim/lm32/ChangeLog b/sim/lm32/ChangeLog
index 689eb6461af..6d2d238d66f 100644
--- a/sim/lm32/ChangeLog
+++ b/sim/lm32/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* arch.c (sim_machs): Rename to ...
+	(lm32_sim_machs): ... this.
+	* sim-if.c (lm32_sim_machs): New decl.
+	(sim_open): Set STATE_MACH.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* arch.c (sim_machs): Mark const.
diff --git a/sim/lm32/arch.c b/sim/lm32/arch.c
index 72fe4b43b87..4c485140fdb 100644
--- a/sim/lm32/arch.c
+++ b/sim/lm32/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const lm32_sim_machs[] =
 {
 #ifdef HAVE_CPU_LM32BF
   & lm32_mach,
diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c
index 0142868834d..abb9ad7b042 100644
--- a/sim/lm32/sim-if.c
+++ b/sim/lm32/sim-if.c
@@ -80,6 +80,8 @@ find_limit (SIM_DESC sd)
   return (addr + 65536) & ~(0xffffUL);
 }
 
+extern const SIM_MACH * const lm32_sim_machs[];
+
 /* Create an instance of the simulator.  */
 
 SIM_DESC
@@ -92,6 +94,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   unsigned long base, limit;
 
   /* Set default options before parsing user options.  */
+  STATE_MACHS (sd) = lm32_sim_machs;
   current_alignment = STRICT_ALIGNMENT;
   current_target_byte_order = BFD_ENDIAN_BIG;
 
diff --git a/sim/m32r/ChangeLog b/sim/m32r/ChangeLog
index d8171c600ae..d2abefc90b9 100644
--- a/sim/m32r/ChangeLog
+++ b/sim/m32r/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* arch.c (sim_machs): Rename to ...
+	(m32r_sim_machs): ... this.
+	* sim-if.c (m32r_sim_machs): New decl.
+	(sim_open): Set STATE_MACH.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* arch.c (sim_machs): Mark const.
diff --git a/sim/m32r/arch.c b/sim/m32r/arch.c
index 4b789759eb6..b25cd3f990c 100644
--- a/sim/m32r/arch.c
+++ b/sim/m32r/arch.c
@@ -24,7 +24,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const m32r_sim_machs[] =
 {
 #ifdef HAVE_CPU_M32RBF
   & m32r_mach,
diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c
index 3d8db0332fd..33ae7c106e3 100644
--- a/sim/m32r/sim-if.c
+++ b/sim/m32r/sim-if.c
@@ -44,6 +44,8 @@ free_state (SIM_DESC sd)
   sim_state_free (sd);
 }
 
+extern const SIM_MACH * const m32r_sim_machs[];
+
 /* Create an instance of the simulator.  */
 
 SIM_DESC
@@ -55,6 +57,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   int i;
 
   /* Set default options before parsing user options.  */
+  STATE_MACHS (sd) = m32r_sim_machs;
   current_alignment = STRICT_ALIGNMENT;
   current_target_byte_order = BFD_ENDIAN_BIG;
 
diff --git a/sim/or1k/ChangeLog b/sim/or1k/ChangeLog
index 89a89aca725..94e7e0e8c2c 100644
--- a/sim/or1k/ChangeLog
+++ b/sim/or1k/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* arch.c (sim_machs): Rename to ...
+	(or1k_sim_machs): ... this.
+	* sim-if.c (or1k_sim_machs): New decl.
+	(sim_open): Set STATE_MACH.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* arch.c (sim_machs): Mark const.
diff --git a/sim/or1k/arch.c b/sim/or1k/arch.c
index ef3c403c943..87b37249fb3 100644
--- a/sim/or1k/arch.c
+++ b/sim/or1k/arch.c
@@ -25,7 +25,7 @@ This file is part of the GNU simulators.
 #include "sim-main.h"
 #include "bfd.h"
 
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const or1k_sim_machs[] =
 {
 #ifdef HAVE_CPU_OR1K32BF
   & or32_mach,
diff --git a/sim/or1k/sim-if.c b/sim/or1k/sim-if.c
index 06d7dcb61b2..e8353887c82 100644
--- a/sim/or1k/sim-if.c
+++ b/sim/or1k/sim-if.c
@@ -150,6 +150,8 @@ or1k_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt, char *arg,
   return SIM_RC_FAIL;
 }
 
+extern const SIM_MACH * const or1k_sim_machs[];
+
 /* Create an instance of the simulator.  */
 
 SIM_DESC
@@ -161,6 +163,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   int i;
 
   /* Set default options before parsing user options.  */
+  STATE_MACHS (sd) = or1k_sim_machs;
   current_target_byte_order = BFD_ENDIAN_BIG;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
diff --git a/sim/riscv/ChangeLog b/sim/riscv/ChangeLog
index 69c0808ce32..1c98ed58338 100644
--- a/sim/riscv/ChangeLog
+++ b/sim/riscv/ChangeLog
@@ -1,3 +1,10 @@
+2021-06-30  Mike Frysinger  <vapier@gentoo.org>
+
+	* interp.c (sim_open): Set STATE_MACHS.
+	(riscv_sim_machs): New decl.
+	* machs.c (sim_machs): Rename to ...
+	(riscv_sim_machs): ... this.
+
 2021-06-29  Mike Frysinger  <vapier@gentoo.org>
 
 	* machs.c (sim_machs): Mark const.
diff --git a/sim/riscv/interp.c b/sim/riscv/interp.c
index 8b96677634f..8908ed12ae8 100644
--- a/sim/riscv/interp.c
+++ b/sim/riscv/interp.c
@@ -53,6 +53,8 @@ free_state (SIM_DESC sd)
   sim_state_free (sd);
 }
 
+extern const SIM_MACH * const riscv_sim_machs[];
+
 SIM_DESC
 sim_open (SIM_OPEN_KIND kind, host_callback *callback,
 	  struct bfd *abfd, char * const *argv)
@@ -63,6 +65,7 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
 				       sizeof (struct riscv_sim_state));
 
   /* Set default options before parsing user options.  */
+  STATE_MACHS (sd) = riscv_sim_machs;
   current_target_byte_order = BFD_ENDIAN_LITTLE;
 
   /* The cpu data is kept in a separately allocated chunk of memory.  */
diff --git a/sim/riscv/machs.c b/sim/riscv/machs.c
index eb75a1dd200..339e5ba4754 100644
--- a/sim/riscv/machs.c
+++ b/sim/riscv/machs.c
@@ -111,7 +111,7 @@ static const SIM_MACH rv128i_mach =
 #endif
 
 /* Order matters here.  */
-const SIM_MACH * const sim_machs[] =
+const SIM_MACH * const riscv_sim_machs[] =
 {
 #if WITH_TARGET_WORD_BITSIZE >= 128
   &rv128i_mach,
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic