]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/common/sim-model.h
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / sim / common / sim-model.h
CommitLineData
f5cd4d75
DE
1/* Architecture, machine, and model support.
2 Copyright (C) 1997, 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
4
5This file is part of GDB, the GNU debugger.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License along
18with this program; if not, write to the Free Software Foundation, Inc.,
1959 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21/* Nomenclature:
22 architecture = one of sparc, mips, sh, etc.
23 in the sparc architecture, mach = one of v6, v7, v8, sparclite, etc.
24 in the v8 mach, model = one of supersparc, etc.
25*/
26
27/* This file is intended to be included by sim-basics.h. */
28
29#ifndef SIM_MODEL_H
30#define SIM_MODEL_H
31
32/* Function unit and instruction timing support.
33 ??? This is obviously insufficiently general.
34 It's useful but it needs elaborating upon. */
35
36typedef struct {
37 unsigned char name; /* actually a UNIT_TYPE enum */
38 unsigned char issue;
39 unsigned char done;
40} UNIT;
41
42#ifndef MAX_UNITS
43#define MAX_UNITS 1
44#endif
45
46typedef int (MODEL_FN) (sim_cpu *, void *);
47
48typedef struct {
49 /* This is an integer that identifies this insn.
50 How this works is up to the target. */
51 int num;
52
53 /* Function to handle insn-specific profiling. */
54 MODEL_FN *model_fn;
55
56 /* Array of function units used by this insn. */
57 UNIT units[MAX_UNITS];
58} INSN_TIMING;
59
60/* Struct to describe various implementation properties of a cpu.
61 When multiple cpu variants are supported, the sizes of some structs
62 can vary. */
63
64typedef struct {
65 /* The size of the SIM_CPU struct. */
66 int sim_cpu_size;
67#define IMP_PROPS_SIM_CPU_SIZE(cpu_props) ((cpu_props)->sim_cpu_size)
68 /* An SCACHE element can vary in size, depending on the selected cpu.
69 This is zero if the SCACHE isn't in use for this variant. */
70 int scache_elm_size;
71#define IMP_PROPS_SCACHE_ELM_SIZE(cpu_props) ((cpu_props)->scache_elm_size)
72} MACH_IMP_PROPERTIES;
73
74/* A machine variant. */
75
76typedef struct {
77 const char *name;
78#define MACH_NAME(m) ((m)->name)
79 /* This is the argument to bfd_scan_arch. */
80 const char *bfd_name;
81#define MACH_BFD_NAME(m) ((m)->bfd_name)
82 int word_bitsize;
83#define MACH_WORD_BITSIZE(m) ((m)->word_bitsize)
84 int addr_bitsize;
85#define MACH_ADDR_BITSIZE(m) ((m)->addr_bitsize)
86
87 /* Pointer to null-entry terminated table of models of this mach.
88 The default is the first one. */
89 const struct model *models;
90#define MACH_MODELS(m) ((m)->models)
91
92 /* Pointer to the implementation properties of this mach. */
93 const MACH_IMP_PROPERTIES *imp_props;
94#define MACH_IMP_PROPS(m) ((m)->imp_props)
95
96 /* Called by sim_model_set when the model of a cpu is set. */
97 void (* init_cpu) (sim_cpu *);
98#define MACH_INIT_CPU(m) ((m)->init_cpu)
99} MACH;
100
101/* A model (implementation) of a machine. */
102
103typedef struct model {
104 const char *name;
105#define MODEL_NAME(m) ((m)->name)
106 const MACH *mach;
107#define MODEL_MACH(m) ((m)->mach)
108 /* An enum that distinguished the model. */
109 int num;
110#define MODEL_NUM(m) ((m)->num)
111 /* Pointer to timing table for this model. */
112 const INSN_TIMING *timing;
113#define MODEL_TIMING(m) ((m)->timing)
114 void (* init) (sim_cpu *);
115#define MODEL_INIT(m) ((m)->init)
116} MODEL;
117
118/* Tables of supported machines. */
119/* ??? In a simulator of multiple architectures, will need multiple copies of
120 this. Have an `archs' array that contains a pointer to the machs array
121 for each (which in turn has a pointer to the models array for each). */
122extern const MACH *sim_machs[];
123
124/* Model module handlers. */
125extern MODULE_INSTALL_FN sim_model_install;
126
127/* Support routines. */
128extern void sim_model_set (SIM_DESC sd, sim_cpu *cpu, const MODEL *model);
129extern const MODEL * sim_model_lookup (const char *name);
130extern const MACH * sim_mach_lookup (const char *name);
131
132#endif /* SIM_MODEL_H */