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.
This commit is contained in:
Mike Frysinger
2021-06-28 21:42:56 -04:00
parent f8261de1b2
commit 1c636da093
35 changed files with 167 additions and 46 deletions

View File

@@ -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 */