sim: sim-model: build for everyone

Rather than include this for some targets, set it up so we can build it
all the time via the common code.  This makes it easier for targets to
opt into it when they're ready, increases build coverage, and allows us
to centralize much of the logic.

We also get to delete tconfig.h from two more targets -- they were
setting WITH_DEVICES to 0 which has the same behavior as not defining
it at all.

While the SIM_HAVE_MODEL knob is gone, we now have WITH_MODEL_P, but it
is only used by the common sim-model code.  We use it to declare dummy
model lists when the arch hasn't created its own.
This commit is contained in:
Mike Frysinger 2015-12-25 04:27:27 -05:00
parent 8a0ebee658
commit 0d58595077
29 changed files with 75 additions and 49 deletions

View File

@ -1,3 +1,8 @@
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-model.o.
* tconfig.h (SIM_HAVE_MODEL): Delete.
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* machs.c: Rename MACH to SIM_MACH, MACH_IMP_PROPERTIES to

View File

@ -28,7 +28,6 @@ SIM_OBJS = \
interp.o \
machs.o \
sim-hload.o \
sim-model.o \
sim-resume.o
INCLUDE = bfin-sim.h

View File

@ -3,6 +3,3 @@
/* We use this so that we are passed the requesting CPU for HW acesses.
Common sim core by default sets hw_system_cpu to NULL for WITH_HW. */
#define WITH_DEVICES 1
/* ??? Temporary hack until model support unified. */
#define SIM_HAVE_MODEL

View File

@ -1,3 +1,18 @@
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* Make-common.in (SIM_NEW_COMMON_OBJS): Add sim-model.o.
* cgen-types.h (SIM_HAVE_MODEL): Delete.
* sim-base.h: Always include sim-model.h.
* sim-config.h (WITH_DEFAULT_MODEL): Delete.
* sim-cpu.h (sim_cpu_base): Always declare mach/model members.
* sim-model.c (sim_model_init): Return when !WITH_MODEL_P.
[!WITH_MODEL_P] (sim_machs): Define.
* sim-model.h: Add some developer docs.
[!WITH_DEFAULT_MODEL] (mach_attr, WITH_DEFAULT_MODEL): Define.
(WITH_MODEL_P): Define.
* sim-module.c (modules): Always include sim_model_install.
* sim-profile.h (WITH_PROFILE_MODEL_P): Delete.
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* sim-cpu.h: Rename MACH to SIM_MACH and MODEL to SIM_MODEL.

View File

@ -190,6 +190,7 @@ SIM_NEW_COMMON_OBJS = \
sim-info.o \
sim-load.o \
sim-memopt.o \
sim-model.o \
sim-module.o \
sim-options.o \
sim-profile.o \

View File

@ -26,10 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Miscellaneous cgen configury defined here as this file gets
included soon enough. */
/* Indicate we support --profile-model. */
#undef SIM_HAVE_MODEL
#define SIM_HAVE_MODEL
/* Indicate we support --{profile,trace}-{range,function}. */
#undef SIM_HAVE_ADDR_RANGE
#define SIM_HAVE_ADDR_RANGE

View File

@ -82,9 +82,7 @@ typedef struct _sim_cpu sim_cpu;
#include "sim-core.h"
#include "sim-events.h"
#include "sim-profile.h"
#ifdef SIM_HAVE_MODEL
#include "sim-model.h"
#endif
#include "sim-io.h"
#include "sim-engine.h"
#include "sim-watch.h"

View File

@ -524,10 +524,6 @@ extern int current_floating_point;
? WITH_MODEL \
: current_model)
#ifndef WITH_DEFAULT_MODEL
#define WITH_DEFAULT_MODEL DEFAULT_MODEL
#endif
#define MODEL_ISSUE_IGNORE (-1)
#define MODEL_ISSUE_PROCESS 1

View File

@ -100,7 +100,6 @@ typedef struct {
PROFILE_DATA profile_data;
#define CPU_PROFILE_DATA(cpu) (& (cpu)->base.profile_data)
#ifdef SIM_HAVE_MODEL
/* Machine tables for this cpu. See sim-model.h. */
const SIM_MACH *mach;
#define CPU_MACH(cpu) ((cpu)->base.mach)
@ -110,7 +109,6 @@ typedef struct {
/* Model data (profiling state, etc.). */
void *model_data;
#define CPU_MODEL_DATA(cpu) ((cpu)->base.model_data)
#endif
/* Routines to fetch/store registers. */
CPUREG_FETCH_FN *reg_fetch;

View File

@ -190,6 +190,9 @@ 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
@ -241,3 +244,12 @@ 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 *sim_machs[] =
{
NULL
};
#endif

View File

@ -21,6 +21,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
architecture = one of sparc, mips, sh, etc.
in the sparc architecture, mach = one of v6, v7, v8, sparclite, etc.
in the v8 mach, model = one of supersparc, etc.
To use the model framework, your arch needs to do a few things:
(1) Call SIM_AC_OPTION_DEFAULT_MODEL() in configure.ac.
(2) Define enum mach_attr in sim-main.h.
(3) Define sim_machs array (and all the callbacks it uses).
*/
/* This file is intended to be included by sim-basics.h. */
@ -42,6 +47,15 @@ typedef struct {
#define MAX_UNITS 1
#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
# define WITH_MODEL_P 1
#endif
typedef int (MODEL_FN) (sim_cpu *, void *);
typedef struct {

View File

@ -40,9 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
static MODULE_INSTALL_FN * const modules[] = {
standard_install,
sim_events_install,
#ifdef SIM_HAVE_MODEL
sim_model_install,
#endif
#if WITH_ENGINE
sim_engine_install,
#endif

View File

@ -102,12 +102,6 @@ SIM_RC sim_profile_set_option (SIM_DESC sd_, const char *name_, int idx_,
#define WITH_PROFILE_MEMORY_P 0
#endif
/* Only build MODEL code when the target simulator has support for it */
#ifndef SIM_HAVE_MODEL
#undef WITH_PROFILE_MODEL_P
#define WITH_PROFILE_MODEL_P 0
#endif
/* Profiling install handler. */
MODULE_INSTALL_FN profile_install;

View File

@ -1,3 +1,8 @@
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-model.o.
* tconfig.h (SIM_HAVE_MODEL): Delete.
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* arch.c: Rename MACH to SIM_MACH.

View File

@ -24,7 +24,6 @@ CRISV32F_OBJS = crisv32f.o cpuv32.o decodev32.o modelv32.o mloopv32f.o
SIM_OBJS = \
$(SIM_NEW_COMMON_OBJS) \
sim-model.o \
cgen-utils.o cgen-trace.o cgen-scache.o \
cgen-run.o \
sim-if.o arch.o \

View File

@ -27,6 +27,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* For MSPR support. FIXME: revisit. */
#define WITH_DEVICES 1
#define SIM_HAVE_MODEL
#endif /* CRIS_TCONFIG_H */

View File

@ -1,3 +1,8 @@
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-model.o.
* tconfig.h (SIM_HAVE_MODEL): Delete.
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* arch.c: Rename MACH to SIM_MACH.

View File

@ -22,7 +22,6 @@ FRV_OBJS = frv.o cpu.o decode.o sem.o model.o mloop.o cgen-par.o
SIM_OBJS = \
$(SIM_NEW_COMMON_OBJS) \
sim-hload.o \
sim-model.o \
cgen-utils.o cgen-trace.o cgen-scache.o cgen-fpu.o cgen-accfp.o \
cgen-run.o \
sim-if.o arch.o \

View File

@ -2,6 +2,3 @@
/* For MSPR support. FIXME: revisit. */
#define WITH_DEVICES 1
/* ??? Temporary hack until model support unified. */
#define SIM_HAVE_MODEL

View File

@ -1,3 +1,8 @@
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-model.o.
* tconfig.h: Delete file.
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* arch.c: Rename MACH to SIM_MACH.

View File

@ -22,7 +22,6 @@ IQ2000_OBJS = iq2000.o cpu.o decode.o sem.o model.o mloop.o
SIM_OBJS = \
$(SIM_NEW_COMMON_OBJS) \
sim-hload.o \
sim-model.o \
cgen-utils.o cgen-trace.o cgen-scache.o \
cgen-run.o \
sim-if.o arch.o \

View File

@ -1,7 +0,0 @@
/* IQ2000 target configuration file. -*- C -*- */
/* For MSPR support. FIXME: revisit. */
#define WITH_DEVICES 0
/* ??? Temporary hack until model support unified. */
#define SIM_HAVE_MODEL

View File

@ -1,3 +1,7 @@
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-model.o.
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* arch.c: Rename MACH to SIM_MACH.

View File

@ -7,7 +7,6 @@
SIM_OBJS = \
$(SIM_NEW_COMMON_OBJS) \
sim-hload.o \
sim-model.o \
cgen-utils.o cgen-trace.o cgen-scache.o \
cgen-run.o \
sim-if.o arch.o \

View File

@ -1,3 +1,7 @@
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-model.o.
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* arch.c: Rename MACH to SIM_MACH.

View File

@ -27,7 +27,6 @@ TRAPS_OBJ = @traps_obj@
SIM_OBJS = \
$(SIM_NEW_COMMON_OBJS) \
sim-hload.o \
sim-model.o \
cgen-utils.o cgen-trace.o cgen-scache.o \
cgen-run.o \
sim-if.o arch.o \

View File

@ -1,3 +1,8 @@
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (SIM_OBJS): Delete sim-model.o.
* tconfig.h: Delete file.
2015-12-25 Mike Frysinger <vapier@gentoo.org>
* arch.c: Rename MACH to SIM_MACH.

View File

@ -24,7 +24,6 @@ SH64_OBJS = sh64.o cpu.o sh-desc.o \
SIM_OBJS = \
$(SIM_NEW_COMMON_OBJS) \
sim-hload.o \
sim-model.o \
cgen-utils.o cgen-trace.o cgen-scache.o \
cgen-run.o \
sim-if.o arch.o \

View File

@ -1,7 +0,0 @@
/* SH64 target configuration file. -*- C -*- */
/* For MSPR support. FIXME: revisit. */
#define WITH_DEVICES 0
/* ??? Temporary hack until model support unified. */
#define SIM_HAVE_MODEL