Initial creation of sourceware repository
[deliverable/binutils-gdb.git] / sim / ppc / ld-insn.h
CommitLineData
c906108c
SS
1/* This file is part of the program psim.
2
3 Copyright (C) 1994,1995,1996, Andrew Cagney <cagney@highland.com.au>
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
7 the Free Software Foundation; either version 2 of the License, or
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
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 */
20
21/*
22# --
23#
24#
25# Fields:
26#
27# 1 Instruction format as a `start-bit,content' pairs.
28# the content is one of a digit, field name or `/' (aka.0)
29#
30# 2 Format specifier
31#
32# 3 Flags: 64 - 64bit only
33# f - floating point enabled required
34#
35# 4 short name
36#
37# 5 Description
38#
39#
40# For flags marked 'model', the fields are interpreted as follows:
41#
42# 1 Not used
43#
44# 2 Not used
45#
46# 3 "macro"
47#
48# 4 String name for model
49#
50# 5 Specific CPU model, must be an identifier
51#
52# 6 Comma separated list of functional units
53
54*/
55
56
57/* Global constants */
58
59enum {
60 max_insn_bit_size = 32,
61};
62
63
64typedef struct _insn_field insn_field;
65struct _insn_field {
66 int first;
67 int last;
68 int width;
69 int is_int;
70 int is_slash;
71 int is_string;
72 int val_int;
73 char *pos_string;
74 char *val_string;
75 insn_field *next;
76 insn_field *prev;
77};
78
79typedef struct _insn_fields insn_fields;
80struct _insn_fields {
81 insn_field *bits[max_insn_bit_size];
82 insn_field *first;
83 insn_field *last;
84 unsigned value;
85};
86
87
88/****************************************************************/
89
90typedef struct _opcode_field opcode_field;
91struct _opcode_field {
92 int first;
93 int last;
94 int is_boolean;
95 unsigned boolean_constant;
96 opcode_field *parent;
97};
98
99
100/****************************************************************/
101
102typedef struct _insn_bits insn_bits;
103struct _insn_bits {
104 int is_expanded;
105 int value;
106 insn_field *field;
107 opcode_field *opcode;
108 insn_bits *last;
109};
110
111
112/****************************************************************/
113
114
115typedef enum {
116 insn_format,
117 insn_form,
118 insn_flags,
119 insn_mnemonic,
120 insn_name,
121 insn_comment,
122 nr_insn_table_fields
123} insn_table_fields;
124
125typedef enum {
126 function_type = insn_format,
127 function_name = insn_name,
128 function_param = insn_comment
129} function_table_fields;
130
131typedef enum {
132 model_name = insn_mnemonic,
133 model_identifer = insn_name,
134 model_default = insn_comment,
135} model_table_fields;
136
137typedef struct _insn insn;
138struct _insn {
139 table_entry *file_entry;
140 insn_fields *fields;
141 insn *next;
142};
143
144typedef struct _insn_undef insn_undef;
145struct _insn_undef {
146 insn_undef *next;
147 char *name;
148};
149
150typedef struct _model model;
151struct _model {
152 model *next;
153 char *name;
154 char *printable_name;
155 char *insn_default;
156 table_model_entry *func_unit_start;
157 table_model_entry *func_unit_end;
158};
159
160typedef struct _insn_table insn_table;
161struct _insn_table {
162 int opcode_nr;
163 insn_bits *expanded_bits;
164 int nr_insn;
165 insn *insns;
166 insn *functions;
167 insn *last_function;
168 decode_table *opcode_rule;
169 opcode_field *opcode;
170 int nr_entries;
171 insn_table *entries;
172 insn_table *sibling;
173 insn_table *parent;
174};
175
176typedef enum {
177 insn_model_name,
178 insn_model_fields,
179 nr_insn_model_table_fields
180} insn_model_table_fields;
181
182
183extern insn_table *load_insn_table
184(const char *file_name,
185 decode_table *decode_rules,
186 filter *filters);
187
188model *models;
189model *last_model;
190
191insn *model_macros;
192insn *last_model_macro;
193
194insn *model_functions;
195insn *last_model_function;
196
197insn *model_internal;
198insn *last_model_internal;
199
200insn *model_static;
201insn *last_model_static;
202
203insn *model_data;
204insn *last_model_data;
205
206int max_model_fields_len;
207
208extern void insn_table_insert_insn
209(insn_table *table,
210 table_entry *file_entry,
211 insn_fields *fields);
212
213
214/****************************************************************/
215
216/****************************************************************/
217
218typedef void leaf_handler
219(insn_table *entry,
220 lf *file,
221 void *data,
222 int depth);
223
224typedef void insn_handler
225(insn_table *table,
226 lf *file,
227 void *data,
228 insn *instruction,
229 int depth);
230
231typedef void padding_handler
232(insn_table *table,
233 lf *file,
234 void *data,
235 int depth,
236 int opcode_nr);
237
238
239extern void insn_table_traverse_tree
240(insn_table *table,
241 lf *file,
242 void *data,
243 int depth,
244 leaf_handler *start,
245 insn_handler *handler,
246 leaf_handler *end,
247 padding_handler *padding);
248
249
250extern void insn_table_traverse_insn
251(insn_table *table,
252 lf *file,
253 void *data,
254 insn_handler *handler);
255
256
257
258/****************************************************************/
259
260typedef void function_handler
261(insn_table *table,
262 lf *file,
263 void *data,
264 table_entry *function);
265
266extern void
267insn_table_traverse_function
268(insn_table *table,
269 lf *file,
270 void *data,
271 function_handler *leaf);
272
273/****************************************************************/
274
275
276
277extern void insn_table_expand_insns
278(insn_table *table);
279
280extern int insn_table_depth
281(insn_table *table);
This page took 0.031864 seconds and 4 git commands to generate.