Commit | Line | Data |
---|---|---|
feaee4bd AC |
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. */ | |
c906108c SS |
23 | |
24 | ||
25 | typedef struct _opcode_field opcode_field; | |
4e0bf4c4 AC |
26 | struct _opcode_field |
27 | { | |
c906108c SS |
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; | |
4e0bf4c4 AC |
38 | struct _opcode_bits |
39 | { | |
c906108c SS |
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; | |
4e0bf4c4 AC |
49 | struct _insn_opcodes |
50 | { | |
c906108c SS |
51 | opcode_field *opcode; |
52 | insn_opcodes *next; | |
53 | }; | |
54 | ||
55 | typedef struct _insn_list insn_list; | |
4e0bf4c4 AC |
56 | struct _insn_list |
57 | { | |
c906108c SS |
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; | |
4e0bf4c4 AC |
77 | struct _gen_entry |
78 | { | |
c906108c SS |
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; | |
4e0bf4c4 | 85 | gen_entry *parent; /* parent has the opcode* data */ |
c906108c SS |
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 | ||
4e0bf4c4 AC |
107 | struct _gen_list |
108 | { | |
c906108c SS |
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; | |
4e0bf4c4 AC |
117 | struct _gen_table |
118 | { | |
c906108c SS |
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 | ||
4e0bf4c4 | 131 | extern gen_table *make_gen_tables (insn_table *isa, decode_table *rules); |
c906108c SS |
132 | |
133 | ||
4e0bf4c4 | 134 | extern void gen_tables_expand_insns (gen_table *gen); |
c906108c | 135 | |
4e0bf4c4 | 136 | extern void gen_tables_expand_semantics (gen_table *gen); |
c906108c | 137 | |
4e0bf4c4 | 138 | extern int gen_entry_depth (gen_entry *table); |
c906108c SS |
139 | |
140 | ||
141 | ||
142 | /* Traverse the created data structure */ | |
143 | ||
144 | typedef void gen_entry_handler | |
4e0bf4c4 | 145 | (lf *file, gen_entry *entry, int depth, void *data); |
c906108c SS |
146 | |
147 | extern void gen_entry_traverse_tree | |
4e0bf4c4 AC |
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); | |
c906108c SS |
153 | |
154 | ||
155 | ||
156 | /* Misc functions - actually in igen.c */ | |
157 | ||
158 | ||
159 | /* Cache functions: */ | |
160 | ||
4e0bf4c4 | 161 | extern int print_icache_function_formal (lf *file, int nr_prefetched_words); |
c906108c | 162 | |
4e0bf4c4 | 163 | extern int print_icache_function_actual (lf *file, int nr_prefetched_words); |
c906108c | 164 | |
4e0bf4c4 | 165 | extern int print_icache_function_type (lf *file); |
c906108c | 166 | |
4e0bf4c4 | 167 | extern int print_semantic_function_formal (lf *file, int nr_prefetched_words); |
c906108c | 168 | |
4e0bf4c4 | 169 | extern int print_semantic_function_actual (lf *file, int nr_prefetched_words); |
c906108c | 170 | |
4e0bf4c4 | 171 | extern int print_semantic_function_type (lf *file); |
c906108c | 172 | |
4e0bf4c4 | 173 | extern int print_idecode_function_formal (lf *file, int nr_prefetched_words); |
c906108c | 174 | |
4e0bf4c4 | 175 | extern int print_idecode_function_actual (lf *file, int nr_prefetched_words); |
c906108c | 176 | |
4e0bf4c4 AC |
177 | typedef enum |
178 | { | |
c906108c SS |
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 | |
4e0bf4c4 AC |
185 | } |
186 | lf_function_name_prefixes; | |
c906108c | 187 | |
4e0bf4c4 AC |
188 | typedef enum |
189 | { | |
c906108c SS |
190 | is_function_declaration = 0, |
191 | is_function_definition = 1, | |
192 | is_function_variable, | |
4e0bf4c4 AC |
193 | } |
194 | function_decl_type; | |
c906108c SS |
195 | |
196 | extern int print_function_name | |
4e0bf4c4 AC |
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); | |
c906108c SS |
202 | |
203 | extern void print_my_defines | |
4e0bf4c4 AC |
204 | (lf *file, |
205 | const char *basename, const char *format_name, opcode_bits *expanded_bits); | |
c906108c | 206 | |
4e0bf4c4 | 207 | extern void print_itrace (lf *file, insn_entry * insn, int idecode); |
c906108c | 208 | |
4e0bf4c4 | 209 | extern void print_sim_engine_abort (lf *file, const char *message); |
c906108c SS |
210 | |
211 | ||
212 | extern void print_include (lf *file, igen_module module); | |
4e0bf4c4 | 213 | extern void print_include_inline (lf *file, igen_module module); |
c906108c | 214 | extern void print_includes (lf *file); |