2002-11-21 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / sim / igen / gen.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 typedef struct _opcode_field opcode_field;
26 struct _opcode_field {
27 int word_nr;
28 int first;
29 int last;
30 int is_boolean;
31 int nr_opcodes;
32 unsigned boolean_constant;
33 opcode_field *parent;
34 };
35
36 typedef struct _opcode_bits opcode_bits;
37 struct _opcode_bits {
38 int value;
39 int first;
40 int last;
41 insn_field_entry *field;
42 opcode_field *opcode;
43 opcode_bits *next;
44 };
45
46 typedef struct _insn_opcodes insn_opcodes;
47 struct _insn_opcodes {
48 opcode_field *opcode;
49 insn_opcodes *next;
50 };
51
52 typedef struct _insn_list insn_list;
53 struct _insn_list {
54 /* the instruction */
55 insn_entry *insn;
56 /* list of non constant bits that have been made constant */
57 opcode_bits *expanded_bits;
58 /* list of the various opcode field paths used to reach this
59 instruction */
60 insn_opcodes *opcodes;
61 /* number of prefetched words for this instruction */
62 int nr_prefetched_words;
63 /* The semantic function list_entry corresponding to this insn */
64 insn_list *semantic;
65 /* linked list */
66 insn_list *next;
67 };
68
69 /* forward */
70 typedef struct _gen_list gen_list;
71
72 typedef struct _gen_entry gen_entry;
73 struct _gen_entry {
74
75 /* as an entry in a table */
76 int word_nr;
77 int opcode_nr;
78 gen_entry *sibling;
79 opcode_bits *expanded_bits;
80 gen_entry *parent; /* parent has the opcode* data */
81
82 /* as a table containing entries */
83 decode_table *opcode_rule;
84 opcode_field *opcode;
85 int nr_prefetched_words;
86 int nr_entries;
87 gen_entry *entries;
88
89 /* as both an entry and a table */
90 int nr_insns;
91 insn_list *insns;
92
93 /* if siblings are being combined */
94 gen_entry *combined_next;
95 gen_entry *combined_parent;
96
97 /* our top-of-tree */
98 gen_list *top;
99 };
100
101
102 struct _gen_list {
103 model_entry *model;
104 insn_table *isa;
105 gen_entry *table;
106 gen_list *next;
107 };
108
109
110 typedef struct _gen_table gen_table;
111 struct _gen_table {
112 /* list of all the instructions */
113 insn_table *isa;
114 /* list of all the semantic functions */
115 decode_table *rules;
116 /* list of all the generated instruction tables */
117 gen_list *tables;
118 /* list of all the semantic functions */
119 int nr_semantics;
120 insn_list *semantics;
121 };
122
123
124 extern gen_table *make_gen_tables
125 (insn_table *isa,
126 decode_table *rules);
127
128
129 extern void gen_tables_expand_insns
130 (gen_table *gen);
131
132 extern void gen_tables_expand_semantics
133 (gen_table *gen);
134
135 extern int gen_entry_depth
136 (gen_entry *table);
137
138
139
140 /* Traverse the created data structure */
141
142 typedef void gen_entry_handler
143 (lf *file,
144 gen_entry *entry,
145 int depth,
146 void *data);
147
148 extern void gen_entry_traverse_tree
149 (lf *file,
150 gen_entry *table,
151 int depth,
152 gen_entry_handler *start,
153 gen_entry_handler *leaf,
154 gen_entry_handler *end,
155 void *data);
156
157
158
159 /* Misc functions - actually in igen.c */
160
161
162 /* Cache functions: */
163
164 extern int print_icache_function_formal
165 (lf *file, int nr_prefetched_words);
166
167 extern int print_icache_function_actual
168 (lf *file, int nr_prefetched_words);
169
170 extern int print_icache_function_type
171 (lf *file);
172
173 extern int print_semantic_function_formal
174 (lf *file, int nr_prefetched_words);
175
176 extern int print_semantic_function_actual
177 (lf *file, int nr_prefetched_words);
178
179 extern int print_semantic_function_type
180 (lf *file);
181
182 extern int print_idecode_function_formal
183 (lf *file, int nr_prefetched_words);
184
185 extern int print_idecode_function_actual
186 (lf *file, int nr_prefetched_words);
187
188 typedef enum {
189 function_name_prefix_semantics,
190 function_name_prefix_idecode,
191 function_name_prefix_itable,
192 function_name_prefix_icache,
193 function_name_prefix_engine,
194 function_name_prefix_none
195 } lf_function_name_prefixes;
196
197 typedef enum {
198 is_function_declaration = 0,
199 is_function_definition = 1,
200 is_function_variable,
201 } function_decl_type;
202
203 extern int print_function_name
204 (lf *file,
205 const char *basename,
206 const char *format_name,
207 const char *model_name,
208 opcode_bits *expanded_bits,
209 lf_function_name_prefixes prefix);
210
211 extern void print_my_defines
212 (lf *file,
213 const char *basename,
214 const char *format_name,
215 opcode_bits *expanded_bits);
216
217 extern void print_itrace
218 (lf *file,
219 insn_entry *insn,
220 int idecode);
221
222 extern void print_sim_engine_abort
223 (lf *file,
224 const char *message);
225
226
227 extern void print_include (lf *file, igen_module module);
228 extern void print_include_inline (lf *file, igen_module module);
229 extern void print_includes (lf *file);
230
This page took 0.055165 seconds and 5 git commands to generate.