summaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-06-28 22:07:44 -0400
committerMike Frysinger <vapier@gentoo.org>2021-06-30 02:57:45 -0400
commitd414eb3e7fc1e82d68e69ba6a9a867b9d9a9dba2 (patch)
treec82ef917cb7fabce6d96e5357474f398b7de73be /sim/common
parent1c636da093f335cd57e7fca0fc25ae9f9e849264 (diff)
downloadbinutils-gdb-d414eb3e7fc1e82d68e69ba6a9a867b9d9a9dba2.tar.gz
sim: move default model to the runtime sim state
This kills off another compile-time option by moving the setting to the individual arch runtimes. This will allow dynamic selection by the arch when doing a single build with multiple arches. The sim_model_init rework is a little funky. In the past it was disabled entirely if no default model was set. We maintain the spirit of the logic by gating the fallback logic on whether the port has defined any models.
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/ChangeLog11
-rw-r--r--sim/common/Make-common.in2
-rw-r--r--sim/common/sim-base.h4
-rw-r--r--sim/common/sim-model.c13
-rw-r--r--sim/common/sim-model.h7
5 files changed, 21 insertions, 16 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 63e7f3be345..5b86431c8bb 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,5 +1,16 @@
2021-06-30 Mike Frysinger <vapier@gentoo.org>
+ * Make-common.in (SIM_DEFAULT_MODEL): Delete.
+ * sim-base.h (struct sim_state): Add model_name.
+ (STATE_MODEL_NAME): Define.
+ * sim-model.c (model_option_handler): Set STATE_MODEL_NAME.
+ (sim_model_init): Delete WITH_MODEL_P check. Change
+ WITH_DEFAULT_MODEL to STATE_MODEL_NAME.
+ * sim-model.h (WITH_DEFAULT_MODEL): Delete.
+ (WITH_MODEL_P): Delete.
+
+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.
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 723bda589c9..992fd7f8a6e 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -73,7 +73,6 @@ top_builddir = ..
SHELL = @SHELL@
SIM_BITSIZE = @sim_bitsize@
-SIM_DEFAULT_MODEL = @sim_default_model@
SIM_FLOAT = @sim_float@
SIM_RESERVED_BITS = @sim_reserved_bits@
SIM_SCACHE = @sim_scache@
@@ -195,7 +194,6 @@ CGEN_INCLUDE_DEPS = \
CONFIG_CFLAGS = \
-DHAVE_CONFIG_H \
- $(SIM_DEFAULT_MODEL) \
$(SIM_BITSIZE) \
$(SIM_FLOAT) \
$(SIM_HW_CFLAGS) \
diff --git a/sim/common/sim-base.h b/sim/common/sim-base.h
index 8eae988eb50..674b2d42308 100644
--- a/sim/common/sim-base.h
+++ b/sim/common/sim-base.h
@@ -147,6 +147,10 @@ struct sim_state {
const SIM_MACH * const *machs;
#define STATE_MACHS(sd) ((sd)->machs)
+ /* If non-NULL, the model to select for CPUs. */
+ const char *model_name;
+#define STATE_MODEL_NAME(sd) ((sd)->model_name)
+
/* In standalone simulator, this is the program's arguments passed
on the command line. */
char **prog_argv;
diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c
index 4c5e463f1a0..98dcbeae6cc 100644
--- a/sim/common/sim-model.c
+++ b/sim/common/sim-model.c
@@ -68,6 +68,7 @@ model_option_handler (SIM_DESC sd, sim_cpu *cpu, int opt,
sim_io_eprintf (sd, "unknown model `%s'\n", arg);
return SIM_RC_FAIL;
}
+ STATE_MODEL_NAME (sd) = arg;
sim_model_set (sd, cpu, model);
break;
}
@@ -209,9 +210,6 @@ sim_model_init (SIM_DESC sd)
{
SIM_CPU *cpu;
- if (!WITH_MODEL_P)
- return SIM_RC_OK;
-
/* If both cpu model and state architecture are set, ensure they're
compatible. If only one is set, set the other. If neither are set,
use the default model. STATE_ARCHITECTURE is the bfd_arch_info data
@@ -222,10 +220,11 @@ sim_model_init (SIM_DESC sd)
cpu = STATE_CPU (sd, 0);
if (! STATE_ARCHITECTURE (sd)
- && ! CPU_MACH (cpu))
+ && ! CPU_MACH (cpu)
+ && STATE_MODEL_NAME (sd))
{
/* Set the default model. */
- const SIM_MODEL *model = sim_model_lookup (sd, WITH_DEFAULT_MODEL);
+ const SIM_MODEL *model = sim_model_lookup (sd, STATE_MODEL_NAME (sd));
SIM_ASSERT (model != NULL);
sim_model_set (sd, NULL, model);
}
@@ -242,7 +241,7 @@ sim_model_init (SIM_DESC sd)
return SIM_RC_FAIL;
}
}
- else if (STATE_ARCHITECTURE (sd))
+ else if (STATE_ARCHITECTURE (sd) && STATE_MACHS (sd))
{
/* Use the default model for the selected machine.
The default model is the first one in the list. */
@@ -257,7 +256,7 @@ sim_model_init (SIM_DESC sd)
}
sim_model_set (sd, NULL, MACH_MODELS (mach));
}
- else
+ else if (CPU_MACH (cpu))
{
STATE_ARCHITECTURE (sd) = bfd_scan_arch (MACH_BFD_NAME (CPU_MACH (cpu)));
}
diff --git a/sim/common/sim-model.h b/sim/common/sim-model.h
index e735feb4b9a..ecef2571766 100644
--- a/sim/common/sim-model.h
+++ b/sim/common/sim-model.h
@@ -47,13 +47,6 @@ typedef struct {
#define MAX_UNITS 1
#endif
-#ifndef WITH_DEFAULT_MODEL
-# define WITH_DEFAULT_MODEL NULL
-# define WITH_MODEL_P 0
-#else
-# define WITH_MODEL_P 1
-#endif
-
typedef int (MODEL_FN) (sim_cpu *, void *);
typedef struct {