aboutsummaryrefslogtreecommitdiff
path: root/sim/common
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-12-25 04:27:27 -0500
committerMike Frysinger <vapier@gentoo.org>2015-12-25 04:40:31 -0500
commit0d58595077841917ad57c9f8d2a61184a504ef40 (patch)
tree700d848c63f82b4284abebb23b1689a2272eb108 /sim/common
parent8a0ebee658862bec66191df192c1d3b09bf0c943 (diff)
downloadgdb-0d58595077841917ad57c9f8d2a61184a504ef40.zip
gdb-0d58595077841917ad57c9f8d2a61184a504ef40.tar.gz
gdb-0d58595077841917ad57c9f8d2a61184a504ef40.tar.bz2
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.
Diffstat (limited to 'sim/common')
-rw-r--r--sim/common/ChangeLog15
-rw-r--r--sim/common/Make-common.in1
-rw-r--r--sim/common/cgen-types.h4
-rw-r--r--sim/common/sim-base.h2
-rw-r--r--sim/common/sim-config.h4
-rw-r--r--sim/common/sim-cpu.h2
-rw-r--r--sim/common/sim-model.c12
-rw-r--r--sim/common/sim-model.h14
-rw-r--r--sim/common/sim-module.c2
-rw-r--r--sim/common/sim-profile.h6
10 files changed, 42 insertions, 20 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index e36895a..09f29bb 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,5 +1,20 @@
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.
* sim-model.c: Likewise.
* sim-model.h: Likewise. Rename MACH_IMP_PROPERTIES to
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 647ec80..2566bf4 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -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 \
diff --git a/sim/common/cgen-types.h b/sim/common/cgen-types.h
index 74dc640..7779393 100644
--- a/sim/common/cgen-types.h
+++ b/sim/common/cgen-types.h
@@ -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
diff --git a/sim/common/sim-base.h b/sim/common/sim-base.h
index cfef6ec..3e15a85 100644
--- a/sim/common/sim-base.h
+++ b/sim/common/sim-base.h
@@ -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"
diff --git a/sim/common/sim-config.h b/sim/common/sim-config.h
index 599b84c..064d936 100644
--- a/sim/common/sim-config.h
+++ b/sim/common/sim-config.h
@@ -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
diff --git a/sim/common/sim-cpu.h b/sim/common/sim-cpu.h
index 20838e8..f998bef 100644
--- a/sim/common/sim-cpu.h
+++ b/sim/common/sim-cpu.h
@@ -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;
diff --git a/sim/common/sim-model.c b/sim/common/sim-model.c
index 0d0c28d..054f0bc 100644
--- a/sim/common/sim-model.c
+++ b/sim/common/sim-model.c
@@ -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
diff --git a/sim/common/sim-model.h b/sim/common/sim-model.h
index 5baa5ce..a206626 100644
--- a/sim/common/sim-model.h
+++ b/sim/common/sim-model.h
@@ -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 {
diff --git a/sim/common/sim-module.c b/sim/common/sim-module.c
index 4f23882..670225b 100644
--- a/sim/common/sim-module.c
+++ b/sim/common/sim-module.c
@@ -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
diff --git a/sim/common/sim-profile.h b/sim/common/sim-profile.h
index 3370f0c..b756af5 100644
--- a/sim/common/sim-profile.h
+++ b/sim/common/sim-profile.h
@@ -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;