]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* This file is part of the program psim. |
2 | ||
d81bb16a | 3 | Copyright 1994, 1995, 1996, 2003 Andrew Cagney |
c906108c SS |
4 | |
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
3fd725ef | 7 | the Free Software Foundation; either version 3 of the License, or |
c906108c SS |
8 | (at your option) any later version. |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
51b318de | 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
17 | |
18 | */ | |
19 | ||
20 | /* | |
21 | # -- | |
22 | # | |
23 | # | |
24 | # Fields: | |
25 | # | |
26 | # 1 Instruction format as a `start-bit,content' pairs. | |
27 | # the content is one of a digit, field name or `/' (aka.0) | |
28 | # | |
29 | # 2 Format specifier | |
30 | # | |
31 | # 3 Flags: 64 - 64bit only | |
32 | # f - floating point enabled required | |
33 | # | |
34 | # 4 short name | |
35 | # | |
36 | # 5 Description | |
37 | # | |
38 | # | |
39 | # For flags marked 'model', the fields are interpreted as follows: | |
40 | # | |
41 | # 1 Not used | |
42 | # | |
43 | # 2 Not used | |
44 | # | |
45 | # 3 "macro" | |
46 | # | |
47 | # 4 String name for model | |
48 | # | |
49 | # 5 Specific CPU model, must be an identifier | |
50 | # | |
51 | # 6 Comma separated list of functional units | |
52 | ||
53 | */ | |
54 | ||
55 | ||
56 | /* Global constants */ | |
57 | ||
58 | enum { | |
59 | max_insn_bit_size = 32, | |
60 | }; | |
61 | ||
62 | ||
63 | typedef struct _insn_field insn_field; | |
64 | struct _insn_field { | |
65 | int first; | |
66 | int last; | |
67 | int width; | |
68 | int is_int; | |
69 | int is_slash; | |
70 | int is_string; | |
71 | int val_int; | |
72 | char *pos_string; | |
73 | char *val_string; | |
74 | insn_field *next; | |
75 | insn_field *prev; | |
76 | }; | |
77 | ||
78 | typedef struct _insn_fields insn_fields; | |
79 | struct _insn_fields { | |
80 | insn_field *bits[max_insn_bit_size]; | |
81 | insn_field *first; | |
82 | insn_field *last; | |
83 | unsigned value; | |
84 | }; | |
85 | ||
86 | ||
87 | /****************************************************************/ | |
88 | ||
89 | typedef struct _opcode_field opcode_field; | |
90 | struct _opcode_field { | |
91 | int first; | |
92 | int last; | |
93 | int is_boolean; | |
94 | unsigned boolean_constant; | |
95 | opcode_field *parent; | |
96 | }; | |
97 | ||
98 | ||
99 | /****************************************************************/ | |
100 | ||
101 | typedef struct _insn_bits insn_bits; | |
102 | struct _insn_bits { | |
103 | int is_expanded; | |
104 | int value; | |
105 | insn_field *field; | |
106 | opcode_field *opcode; | |
107 | insn_bits *last; | |
108 | }; | |
109 | ||
110 | ||
111 | /****************************************************************/ | |
112 | ||
113 | ||
114 | typedef enum { | |
115 | insn_format, | |
116 | insn_form, | |
117 | insn_flags, | |
118 | insn_mnemonic, | |
119 | insn_name, | |
120 | insn_comment, | |
d81bb16a AC |
121 | insn_field_6, |
122 | insn_field_7, | |
c906108c SS |
123 | nr_insn_table_fields |
124 | } insn_table_fields; | |
125 | ||
126 | typedef enum { | |
127 | function_type = insn_format, | |
128 | function_name = insn_name, | |
129 | function_param = insn_comment | |
130 | } function_table_fields; | |
131 | ||
132 | typedef enum { | |
133 | model_name = insn_mnemonic, | |
134 | model_identifer = insn_name, | |
135 | model_default = insn_comment, | |
136 | } model_table_fields; | |
137 | ||
43c4bab0 MG |
138 | typedef enum { |
139 | include_flags = insn_flags, | |
140 | include_path = insn_name, | |
141 | } model_include_fields; | |
142 | ||
d81bb16a AC |
143 | typedef enum { |
144 | cache_type_def = insn_name, | |
145 | cache_derived_name = insn_comment, | |
146 | cache_name = insn_field_6, | |
147 | cache_expression = insn_field_7, | |
148 | } cache_fields; | |
149 | ||
c906108c SS |
150 | typedef struct _insn insn; |
151 | struct _insn { | |
152 | table_entry *file_entry; | |
153 | insn_fields *fields; | |
154 | insn *next; | |
155 | }; | |
156 | ||
157 | typedef struct _insn_undef insn_undef; | |
158 | struct _insn_undef { | |
159 | insn_undef *next; | |
160 | char *name; | |
161 | }; | |
162 | ||
163 | typedef struct _model model; | |
164 | struct _model { | |
165 | model *next; | |
166 | char *name; | |
167 | char *printable_name; | |
168 | char *insn_default; | |
169 | table_model_entry *func_unit_start; | |
170 | table_model_entry *func_unit_end; | |
171 | }; | |
172 | ||
173 | typedef struct _insn_table insn_table; | |
174 | struct _insn_table { | |
175 | int opcode_nr; | |
176 | insn_bits *expanded_bits; | |
177 | int nr_insn; | |
178 | insn *insns; | |
179 | insn *functions; | |
180 | insn *last_function; | |
181 | decode_table *opcode_rule; | |
182 | opcode_field *opcode; | |
183 | int nr_entries; | |
184 | insn_table *entries; | |
185 | insn_table *sibling; | |
186 | insn_table *parent; | |
187 | }; | |
188 | ||
189 | typedef enum { | |
190 | insn_model_name, | |
191 | insn_model_fields, | |
192 | nr_insn_model_table_fields | |
193 | } insn_model_table_fields; | |
194 | ||
195 | ||
196 | extern insn_table *load_insn_table | |
197 | (const char *file_name, | |
198 | decode_table *decode_rules, | |
43c4bab0 | 199 | filter *filters, |
d81bb16a AC |
200 | table_include *includes, |
201 | cache_table **cache_rules); | |
c906108c | 202 | |
ad8464f7 | 203 | extern model *models; |
c906108c | 204 | |
ad8464f7 SH |
205 | extern insn *model_macros; |
206 | extern insn *model_functions; | |
207 | extern insn *model_internal; | |
208 | extern insn *model_static; | |
209 | extern insn *model_data; | |
c906108c | 210 | |
ad8464f7 | 211 | extern int max_model_fields_len; |
c906108c SS |
212 | |
213 | extern void insn_table_insert_insn | |
214 | (insn_table *table, | |
215 | table_entry *file_entry, | |
216 | insn_fields *fields); | |
217 | ||
218 | ||
219 | /****************************************************************/ | |
220 | ||
221 | /****************************************************************/ | |
222 | ||
223 | typedef void leaf_handler | |
224 | (insn_table *entry, | |
225 | lf *file, | |
226 | void *data, | |
227 | int depth); | |
228 | ||
229 | typedef void insn_handler | |
230 | (insn_table *table, | |
231 | lf *file, | |
232 | void *data, | |
233 | insn *instruction, | |
234 | int depth); | |
235 | ||
236 | typedef void padding_handler | |
237 | (insn_table *table, | |
238 | lf *file, | |
239 | void *data, | |
240 | int depth, | |
241 | int opcode_nr); | |
242 | ||
243 | ||
244 | extern void insn_table_traverse_tree | |
245 | (insn_table *table, | |
246 | lf *file, | |
247 | void *data, | |
248 | int depth, | |
249 | leaf_handler *start, | |
250 | insn_handler *handler, | |
251 | leaf_handler *end, | |
252 | padding_handler *padding); | |
253 | ||
254 | ||
255 | extern void insn_table_traverse_insn | |
256 | (insn_table *table, | |
257 | lf *file, | |
258 | void *data, | |
259 | insn_handler *handler); | |
260 | ||
261 | ||
262 | ||
263 | /****************************************************************/ | |
264 | ||
265 | typedef void function_handler | |
266 | (insn_table *table, | |
267 | lf *file, | |
268 | void *data, | |
269 | table_entry *function); | |
270 | ||
271 | extern void | |
272 | insn_table_traverse_function | |
273 | (insn_table *table, | |
274 | lf *file, | |
275 | void *data, | |
276 | function_handler *leaf); | |
277 | ||
278 | /****************************************************************/ | |
279 | ||
280 | ||
281 | ||
282 | extern void insn_table_expand_insns | |
283 | (insn_table *table); | |
284 | ||
285 | extern int insn_table_depth | |
286 | (insn_table *table); |