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