1 /* Architecture, machine, and model support.
2 Copyright (C) 1997-2018 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 architecture = one of sparc, mips, sh, etc.
22 in the sparc architecture, mach = one of v6, v7, v8, sparclite, etc.
23 in the v8 mach, model = one of supersparc, etc.
25 To use the model framework, your arch needs to do a few things:
26 (1) Call SIM_AC_OPTION_DEFAULT_MODEL() in configure.ac.
27 (2) Define enum mach_attr in sim-main.h.
28 (3) Define sim_machs array (and all the callbacks it uses).
31 /* This file is intended to be included by sim-basics.h. */
36 /* Function unit and instruction timing support.
37 ??? This is obviously insufficiently general.
38 It's useful but it needs elaborating upon. */
41 unsigned char name
; /* actually a UNIT_TYPE enum */
50 #ifndef WITH_DEFAULT_MODEL
51 /* Just a stub for ports that do not define models. */
52 enum mach_attr
{ _MACH_NONE
};
53 # define WITH_DEFAULT_MODEL NULL
54 # define WITH_MODEL_P 0
56 # define WITH_MODEL_P 1
59 typedef int (MODEL_FN
) (sim_cpu
*, void *);
62 /* This is an integer that identifies this insn.
63 How this works is up to the target. */
66 /* Function to handle insn-specific profiling. */
69 /* Array of function units used by this insn. */
70 UNIT units
[MAX_UNITS
];
73 /* Struct to describe various implementation properties of a cpu.
74 When multiple cpu variants are supported, the sizes of some structs
78 /* The size of the SIM_CPU struct. */
80 #define IMP_PROPS_SIM_CPU_SIZE(cpu_props) ((cpu_props)->sim_cpu_size)
81 /* An SCACHE element can vary in size, depending on the selected cpu.
82 This is zero if the SCACHE isn't in use for this variant. */
84 #define IMP_PROPS_SCACHE_ELM_SIZE(cpu_props) ((cpu_props)->scache_elm_size)
85 } SIM_MACH_IMP_PROPERTIES
;
87 /* A machine variant. */
91 #define MACH_NAME(m) ((m)->name)
92 /* This is the argument to bfd_scan_arch. */
94 #define MACH_BFD_NAME(m) ((m)->bfd_name)
96 #define MACH_NUM(m) ((m)->num)
99 #define MACH_WORD_BITSIZE(m) ((m)->word_bitsize)
101 #define MACH_ADDR_BITSIZE(m) ((m)->addr_bitsize)
103 /* Pointer to null-entry terminated table of models of this mach.
104 The default is the first one. */
105 const struct model
*models
;
106 #define MACH_MODELS(m) ((m)->models)
108 /* Pointer to the implementation properties of this mach. */
109 const SIM_MACH_IMP_PROPERTIES
*imp_props
;
110 #define MACH_IMP_PROPS(m) ((m)->imp_props)
112 /* Called by sim_model_set when the model of a cpu is set. */
113 void (* init_cpu
) (sim_cpu
*);
114 #define MACH_INIT_CPU(m) ((m)->init_cpu)
116 /* Initialize the simulator engine for this cpu.
117 Used by cgen simulators to initialize the insn descriptor table. */
118 void (* prepare_run
) (sim_cpu
*);
119 #define MACH_PREPARE_RUN(m) ((m)->prepare_run)
122 /* A model (implementation) of a machine. */
124 typedef struct model
{
126 #define MODEL_NAME(m) ((m)->name)
127 const SIM_MACH
*mach
;
128 #define MODEL_MACH(m) ((m)->mach)
129 /* An enum that distinguished the model. */
131 #define MODEL_NUM(m) ((m)->num)
132 /* Pointer to timing table for this model. */
133 const INSN_TIMING
*timing
;
134 #define MODEL_TIMING(m) ((m)->timing)
135 void (* init
) (sim_cpu
*);
136 #define MODEL_INIT(m) ((m)->init)
139 /* Tables of supported machines. */
140 /* ??? In a simulator of multiple architectures, will need multiple copies of
141 this. Have an `archs' array that contains a pointer to the machs array
142 for each (which in turn has a pointer to the models array for each). */
143 extern const SIM_MACH
*sim_machs
[];
145 /* Model module handlers. */
146 extern MODULE_INSTALL_FN sim_model_install
;
148 /* Support routines. */
149 extern void sim_model_set (SIM_DESC sd_
, sim_cpu
*cpu_
, const SIM_MODEL
*model_
);
150 extern const SIM_MODEL
*sim_model_lookup (const char *name_
);
151 extern const SIM_MACH
*sim_mach_lookup (const char *name_
);
152 extern const SIM_MACH
*sim_mach_lookup_bfd_name (const char *bfd_name_
);
154 #endif /* SIM_MODEL_H */