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.
This commit is contained in:
Mike Frysinger
2021-06-28 22:07:44 -04:00
parent 1c636da093
commit d414eb3e7f
62 changed files with 120 additions and 298 deletions

View File

@@ -1,3 +1,14 @@
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.

View File

@@ -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) \

View File

@@ -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;

View File

@@ -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)));
}

View File

@@ -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 {