arm: Support pac_key_* register operand for MRS/MSR in Armv8.1-M Mainline
[binutils-gdb.git] / sim / ppc / ld-insn.h
blob562e6d8742b4e3c425a74dbab9819d5cdcdc6b2e
1 /* This file is part of the program psim.
3 Copyright 1994, 1995, 1996, 2003 Andrew Cagney
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 3 of the License, or
8 (at your option) any later version.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 # --
24 # Fields:
26 # 1 Instruction format as a `start-bit,content' pairs.
27 # the content is one of a digit, field name or `/' (aka.0)
29 # 2 Format specifier
31 # 3 Flags: 64 - 64bit only
32 # f - floating point enabled required
34 # 4 short name
36 # 5 Description
39 # For flags marked 'model', the fields are interpreted as follows:
41 # 1 Not used
43 # 2 Not used
45 # 3 "macro"
47 # 4 String name for model
49 # 5 Specific CPU model, must be an identifier
51 # 6 Comma separated list of functional units
56 /* Global constants */
58 enum {
59 ppc_max_insn_bit_size = 32,
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;
78 typedef struct _insn_fields insn_fields;
79 struct _insn_fields {
80 insn_field *bits[ppc_max_insn_bit_size];
81 insn_field *first;
82 insn_field *last;
83 unsigned value;
87 /****************************************************************/
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;
99 /****************************************************************/
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;
111 /****************************************************************/
114 typedef enum {
115 insn_format,
116 insn_form,
117 insn_flags,
118 insn_mnemonic,
119 insn_name,
120 insn_comment,
121 insn_field_6,
122 insn_field_7,
123 nr_insn_table_fields
124 } insn_table_fields;
126 typedef enum {
127 function_type = insn_format,
128 function_name = insn_name,
129 function_param = insn_comment
130 } function_table_fields;
132 typedef enum {
133 model_name = insn_mnemonic,
134 model_identifer = insn_name,
135 model_default = insn_comment,
136 } model_table_fields;
138 typedef enum {
139 include_flags = insn_flags,
140 include_path = insn_name,
141 } model_include_fields;
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;
150 typedef struct _insn insn;
151 struct _insn {
152 table_entry *file_entry;
153 insn_fields *fields;
154 insn *next;
157 typedef struct _insn_undef insn_undef;
158 struct _insn_undef {
159 insn_undef *next;
160 char *name;
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;
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;
189 typedef enum {
190 insn_model_name,
191 insn_model_fields,
192 nr_insn_model_table_fields
193 } insn_model_table_fields;
196 extern insn_table *load_insn_table
197 (const char *file_name,
198 decode_table *decode_rules,
199 filter *filters,
200 table_include *includes,
201 cache_table **cache_rules);
203 extern model *models;
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;
211 extern int max_model_fields_len;
213 extern void insn_table_insert_insn
214 (insn_table *table,
215 table_entry *file_entry,
216 insn_fields *fields);
219 /****************************************************************/
221 /****************************************************************/
223 typedef void leaf_handler
224 (insn_table *entry,
225 lf *file,
226 void *data,
227 int depth);
229 typedef void insn_handler
230 (insn_table *table,
231 lf *file,
232 void *data,
233 insn *instruction,
234 int depth);
236 typedef void padding_handler
237 (insn_table *table,
238 lf *file,
239 void *data,
240 int depth,
241 int opcode_nr);
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);
255 extern void insn_table_traverse_insn
256 (insn_table *table,
257 lf *file,
258 void *data,
259 insn_handler *handler);
263 /****************************************************************/
265 typedef void function_handler
266 (insn_table *table,
267 lf *file,
268 void *data,
269 table_entry *function);
271 extern void
272 insn_table_traverse_function
273 (insn_table *table,
274 lf *file,
275 void *data,
276 function_handler *leaf);
278 /****************************************************************/
282 extern void insn_table_expand_insns
283 (insn_table *table);
285 extern int insn_table_depth
286 (insn_table *table);