2002-11-21 Andrew Cagney <ac131313@redhat.com>
[external/binutils.git] / sim / igen / igen.h
1 /* The IGEN simulator generator for GDB, the GNU Debugger.
2
3    Copyright 2002 Free Software Foundation, Inc.
4
5    Contributed by Andrew Cagney.
6
7    This file is part of GDB.
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 59 Temple Place - Suite 330,
22    Boston, MA 02111-1307, USA.  */
23
24
25 /* code-generation options: */
26
27 typedef enum {
28
29   /* Transfer control to an instructions semantic code using the the
30      standard call/return mechanism */
31
32   generate_calls,
33
34   /* Transfer control to an instructions semantic code using
35      (computed) goto's instead of the more conventional call/return
36      mechanism */
37
38   generate_jumps,
39
40 } igen_code;
41
42 typedef enum {
43   nia_is_cia_plus_one,
44   nia_is_void,
45   nia_is_invalid,
46 } igen_nia;
47
48
49
50 typedef struct _igen_gen_options igen_gen_options;
51 struct _igen_gen_options {
52   int direct_access;
53   int semantic_icache;
54   int insn_in_icache;
55   int conditional_issue;
56   int slot_verification;
57   int delayed_branch;
58
59   /* If zeroing a register, which one? */
60   int zero_reg;
61   int zero_reg_nr;
62
63   /* should multiple simulators be generated? */
64   int multi_sim;
65
66   /* name of the default multi-sim model */
67   char *default_model;
68
69   /* should the simulator support multi word instructions and if so,
70      what is the max nr of words. */
71   int multi_word;
72
73   /* SMP?  Should the generated code include SMP support (>0) and if
74      so, for how many processors? */
75   int smp;
76
77   /* how should the next instruction address be computed? */
78   igen_nia nia;
79
80   /* nr of instructions in the decoded instruction cache */
81   int icache;
82   int icache_size;
83
84   /* see above */
85   igen_code code;
86 };
87
88
89 typedef struct _igen_trace_options igen_trace_options;
90 struct _igen_trace_options {
91   int rule_selection;
92   int rule_rejection;
93   int insn_insertion;
94   int insn_expansion;
95   int entries;
96   int combine;
97 };
98
99 typedef struct _igen_name {
100   char *u;
101   char *l;
102 } igen_name;
103 typedef struct _igen_module {
104   igen_name prefix;
105   igen_name suffix;
106 } igen_module;
107
108 typedef struct _igen_module_options {
109   igen_module global;
110   igen_module engine;
111   igen_module icache;
112   igen_module idecode;
113   igen_module itable;
114   igen_module semantics;
115   igen_module support;
116 } igen_module_options;
117
118 typedef struct _igen_decode_options igen_decode_options ;
119 struct _igen_decode_options {
120
121   /* Combine tables?  Should the generator make a second pass through
122      each generated table looking for any sub-entries that contain the
123      same instructions.  Those entries being merged into a single
124      table */
125   int combine;
126
127   /* Instruction expansion? Should the semantic code for each
128      instruction, when the oportunity arrises, be expanded according
129      to the variable opcode files that the instruction decode process
130      renders constant */
131   int duplicate;
132
133   /* Treat reserved fields as constant (zero) instead of ignoring
134      their value when determining decode tables */
135   int zero_reserved;
136
137   /* Convert any padded switch rules into goto_switch */
138   int switch_as_goto;
139
140   /* Force all tables to be generated with this lookup mechanism */
141   char *overriding_gen;
142 };
143
144
145 typedef struct _igen_warn_options igen_warn_options;
146 struct _igen_warn_options {
147
148   /* Issue warning about discarded instructions */
149   int discard;
150
151   /* Issue warning about invalid instruction widths */
152   int width;
153
154   /* Issue warning about unimplemented instructions */
155   int unimplemented;
156
157 };
158
159
160
161 typedef struct _igen_options igen_options;
162 struct _igen_options {
163
164   /* What does the instruction look like - bit ordering, size, widths or
165      offesets */
166   int hi_bit_nr;
167   int insn_bit_size;
168   int insn_specifying_widths;
169
170   /* what should global names be prefixed with? */
171   igen_module_options module;
172
173   /* See above for options and flags */
174   igen_gen_options gen;
175
176   /* See above for trace options */
177   igen_trace_options trace;
178
179   /* See above for include options */
180   table_include *include;
181
182   /* See above for decode options */
183   igen_decode_options decode;
184
185   /* Filter set to be used on the flag field of the instruction table */
186   filter *flags_filter;
187
188   /* See above for warn options */
189   igen_warn_options warn;
190
191   /* Be more picky about the input */
192   error_func (*warning);
193
194   /* Model (processor) set - like flags_filter. Used to select the
195      specific ISA within a processor family. */
196   filter *model_filter;
197
198   /* Format name set */
199   filter *format_name_filter;
200 };
201
202 extern igen_options options;
203
204 /* default options - hopefully backward compatible */ \
205 #define INIT_OPTIONS() \
206 do { \
207   memset (&options, 0, sizeof options); \
208   memset (&options.warn, -1, sizeof (options.warn)); \
209   options.hi_bit_nr = 0; \
210   options.insn_bit_size = default_insn_bit_size; \
211   options.insn_specifying_widths = 0; \
212   options.module.global.prefix.u = ""; \
213   options.module.global.prefix.l = ""; \
214   /* the prefixes */ \
215   options.module.engine = options.module.global; \
216   options.module.icache = options.module.global; \
217   options.module.idecode = options.module.global; \
218   options.module.itable = options.module.global; \
219   options.module.semantics = options.module.global; \
220   options.module.support = options.module.global; \
221   /* the suffixes */ \
222   options.module.engine.suffix.l = "engine"; \
223   options.module.engine.suffix.u = "ENGINE"; \
224   options.module.icache.suffix.l = "icache"; \
225   options.module.icache.suffix.u = "ICACHE"; \
226   options.module.idecode.suffix.l = "idecode"; \
227   options.module.idecode.suffix.u = "IDECODE"; \
228   options.module.itable.suffix.l = "itable"; \
229   options.module.itable.suffix.u = "ITABLE"; \
230   options.module.semantics.suffix.l = "semantics"; \
231   options.module.semantics.suffix.u = "SEMANTICS"; \
232   options.module.support.suffix.l = "support"; \
233   options.module.support.suffix.u = "SUPPORT"; \
234   /* misc stuff */ \
235   options.gen.code = generate_calls; \
236   options.gen.icache_size = 1024; \
237   options.warning = warning; \
238 } while (0)