1 /* The IGEN simulator generator for GDB, the GNU Debugger.
3 Copyright 2002-2023 Free Software Foundation, Inc.
5 Contributed by Andrew Cagney.
7 This file is part of GDB.
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 3 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 typedef uint64_t insn_uint
;
27 /* Common among most entries:
29 All non instruction records have the format:
41 record_type_field
= 1,
42 old_record_type_field
= 2,
43 record_filter_flags_field
= 2,
44 record_filter_models_field
= 3,
50 Include the specified file.
64 include_filename_field
= 4,
72 Valid options are: hi-bit-nr (default 0), insn-bit-size (default
73 32), insn-specifying-widths (default true), multi-sim (default false).
86 | "insn-specifying-widths"
102 These update the global options structure. */
107 option_name_field
= 4,
114 /* Macro definitions:
127 [ <name> { "," <arg-list> } ]
135 macro_name_field
= 4,
143 /* Functions and internal routins:
145 NB: <filter-models> and <function-models> are equivalent.
164 "*" [ <processor-list> ]
174 [ ":" <parameter-list> ]
184 function_typedef_field
= 4,
186 function_param_field
,
192 function_model_name_field
= 0,
193 nr_function_model_fields
= 1,
198 old_function_typedef_field
= 0,
199 old_function_type_field
= 2,
200 old_function_name_field
= 4,
201 old_function_param_field
= 5,
202 nr_old_function_fields
= 5, /* parameter-list is optional */
206 typedef struct _function_entry function_entry
;
207 struct _function_entry
217 function_entry
*next
;
221 typedef void function_entry_handler
222 (lf
*file
, const function_entry
*function
, void *data
);
224 extern void function_entry_traverse
226 const function_entry
*functions
,
227 function_entry_handler
* handler
, void *data
);
238 ":" <field-name> { "," <field-name> }
243 <cache-macro-type> ::=
251 | <ident> "_is_" <integer>
254 A cache entry is defined (for an instruction) when all
255 <field-name>s are present as named opcode fields within the
258 SCRATCH and CACHE macros are defined during the cache fill stage
259 while CACHE and COMPUTE macros are defined during the instruction
266 cache_typedef_field
= 4,
268 cache_original_fields_field
,
269 cache_expression_field
,
281 typedef struct _cache_entry cache_entry
;
287 cache_entry_type entry_type
;
289 filter
*original_fields
;
299 <model-processor> ::=
305 ":" <function-unit-data>
344 nr_model_macro_fields
= 4,
345 nr_model_data_fields
= 4,
346 nr_model_static_fields
= nr_function_fields
,
347 nr_model_internal_fields
= nr_function_fields
,
348 nr_model_function_fields
= nr_function_fields
,
351 typedef struct _model_data model_data
;
363 model_name_field
= 4,
364 model_full_name_field
,
365 model_unit_data_field
,
366 nr_model_processor_fields
,
369 typedef struct _model_entry model_entry
;
381 typedef struct _model_table model_table
;
389 function_entry
*statics
;
390 function_entry
*internals
;
391 function_entry
*functions
;
396 /* Instruction format:
398 An instruction is composed of a sequence of N bit instruction
399 words. Each word broken into a number of instruction fields.
400 Those fields being constant (ex. an opcode) or variable (register
404 <insn-field> { "," <insn-field> } ;
407 ( <binary-value-implying-width>
408 | <field-name-implying-width>
409 | [ <start-or-width> "." ] <field>
411 { [ "!" | "=" ] [ <value> | <field-name> ] }
419 | "0b" <binary-value>
425 typedef enum _insn_field_cond_type
427 insn_field_cond_value
,
428 insn_field_cond_field
,
430 insn_field_cond_type
;
431 typedef enum _insn_field_cond_test
436 insn_field_cond_test
;
437 typedef struct _insn_field_cond insn_field_cond
;
438 struct _insn_field_cond
440 insn_field_cond_type type
;
441 insn_field_cond_test test
;
443 struct _insn_field_entry
*field
;
445 insn_field_cond
*next
;
449 typedef enum _insn_field_type
459 typedef struct _insn_field_entry insn_field_entry
;
460 struct _insn_field_entry
466 insn_field_type type
;
470 insn_field_cond
*conditions
;
471 insn_field_entry
*next
;
472 insn_field_entry
*prev
;
475 typedef struct _insn_bit_entry insn_bit_entry
;
476 struct _insn_bit_entry
480 insn_field_entry
*field
;
486 typedef struct _insn_entry insn_entry
; /* forward */
488 typedef struct _insn_word_entry insn_word_entry
;
489 struct _insn_word_entry
491 /* list of sub-fields making up the instruction. bit provides
492 faster access to the field data for bit N. */
493 insn_field_entry
*first
;
494 insn_field_entry
*last
;
495 insn_bit_entry
*bit
[max_insn_bit_size
];
496 /* set of all the string fields */
498 /* For multi-word instructions, The Nth word (from zero). */
499 insn_word_entry
*next
;
504 /* Instruction model:
506 Provides scheduling and other data for the code modeling the
510 "*" [ <processor-list> ]
511 ":" [ <function-unit-data> ]
516 <processor> { "," <processor>" }
519 If the <processor-list> is empty, the model is made the default for
526 insn_model_name_field
= 0,
527 insn_model_unit_data_field
= 1,
528 nr_insn_model_fields
= 1,
531 typedef struct _insn_model_entry insn_model_entry
;
532 struct _insn_model_entry
539 insn_model_entry
*next
;
544 /* Instruction mnemonic:
546 List of assembler mnemonics for the instruction.
549 "\"" <assembler-mnemonic> "\""
550 [ ":" <conditional-expression> ]
554 An assembler mnemonic string has the syntax:
556 <assembler-mnemonic> ::=
557 ( [ "%" <format-spec> ] "<" <func> [ "#" <param-list> ] ">"
562 Where, for instance, the text is translated into a printf format
565 "<FUNC>" : "%ld", (long) FUNC
566 "%<FUNC>..." : "%...", FUNC
567 "%s<FUNC>" : "%s", <%s>FUNC (SD_, FUNC)
568 "%s<FUNC#P1,P2>" : "%s", <%s>FUNC (SD_, P1,P2)
569 "%lx<FUNC>" : "%lx", (unsigned long) FUNC
570 "%08lx<FUNC>" : "%08lx", (unsigned long) FUNC
572 And "<%s>FUNC" denotes a function declared using the "%s" record
583 insn_mnemonic_format_field
= 0,
584 insn_mnemonic_condition_field
= 1,
585 nr_insn_mnemonic_fields
= 1,
588 typedef struct _insn_mnemonic_entry insn_mnemonic_entry
;
589 struct _insn_mnemonic_entry
595 insn_mnemonic_entry
*next
;
603 <insn-word> { "+" <insn-word> }
618 insn_format_name_field
= 1,
619 insn_filter_flags_field
= 2,
620 insn_options_field
= 3,
626 /* typedef struct _insn_entry insn_entry; */
630 filter
*flags
; /* filtered by options.filters */
634 /* the words that make up the instruction. Word provides direct
635 access to word N. Pseudo instructions can be identified by
638 insn_word_entry
*words
;
639 insn_word_entry
**word
;
640 /* a set of all the fields from all the words */
642 /* an array of processor models, missing models are NULL! */
644 insn_model_entry
*models
;
645 insn_model_entry
**model
;
647 /* list of assember formats */
649 insn_mnemonic_entry
*mnemonics
;
656 /* Instruction table:
660 typedef struct _insn_table insn_table
;
667 function_entry
*functions
;
668 insn_entry
*illegal_insn
;
674 extern insn_table
*load_insn_table (const char *file_name
, cache_entry
*cache
);
676 typedef void insn_entry_handler
677 (lf
*file
, const insn_table
*isa
, const insn_entry
*insn
, void *data
);
679 extern void insn_table_traverse_insn
680 (lf
*file
, const insn_table
*isa
, insn_entry_handler
*handler
, void *data
);
686 extern void print_insn_words (lf
*file
, const insn_entry
*insn
);
693 (lf
*file
, const char *prefix
, const insn_field_entry
*field
,
696 void dump_insn_word_entry
697 (lf
*file
, const char *prefix
, const insn_word_entry
*word
,
701 (lf
*file
, const char *prefix
, const insn_entry
*insn
, const char *suffix
);
703 void dump_cache_entries
704 (lf
*file
, const char *prefix
, const cache_entry
*entry
, const char *suffix
);
707 (lf
*file
, const char *prefix
, const insn_table
*isa
, const char *suffix
);