1 /* The IGEN simulator generator for GDB, the GNU Debugger.
3 Copyright 2002-2024 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/>. */
22 #ifndef IGEN_LD_INSN_H
23 #define IGEN_LD_INSN_H
25 typedef uint64_t insn_uint
;
28 /* Common among most entries:
30 All non instruction records have the format:
42 record_type_field
= 1,
43 old_record_type_field
= 2,
44 record_filter_flags_field
= 2,
45 record_filter_models_field
= 3,
51 Include the specified file.
65 include_filename_field
= 4,
73 Valid options are: hi-bit-nr (default 0), insn-bit-size (default
74 32), insn-specifying-widths (default true), multi-sim (default false).
87 | "insn-specifying-widths"
103 These update the global options structure. */
108 option_name_field
= 4,
115 /* Macro definitions:
128 [ <name> { "," <arg-list> } ]
136 macro_name_field
= 4,
144 /* Functions and internal routins:
146 NB: <filter-models> and <function-models> are equivalent.
165 "*" [ <processor-list> ]
175 [ ":" <parameter-list> ]
185 function_typedef_field
= 4,
187 function_param_field
,
193 function_model_name_field
= 0,
194 nr_function_model_fields
= 1,
199 old_function_typedef_field
= 0,
200 old_function_type_field
= 2,
201 old_function_name_field
= 4,
202 old_function_param_field
= 5,
203 nr_old_function_fields
= 5, /* parameter-list is optional */
207 typedef struct _function_entry function_entry
;
208 struct _function_entry
218 function_entry
*next
;
222 typedef void function_entry_handler
223 (lf
*file
, const function_entry
*function
, void *data
);
225 extern void function_entry_traverse
227 const function_entry
*functions
,
228 function_entry_handler
* handler
, void *data
);
239 ":" <field-name> { "," <field-name> }
244 <cache-macro-type> ::=
252 | <ident> "_is_" <integer>
255 A cache entry is defined (for an instruction) when all
256 <field-name>s are present as named opcode fields within the
259 SCRATCH and CACHE macros are defined during the cache fill stage
260 while CACHE and COMPUTE macros are defined during the instruction
267 cache_typedef_field
= 4,
269 cache_original_fields_field
,
270 cache_expression_field
,
282 typedef struct _cache_entry cache_entry
;
288 cache_entry_type entry_type
;
290 filter
*original_fields
;
300 <model-processor> ::=
306 ":" <function-unit-data>
345 nr_model_macro_fields
= 4,
346 nr_model_data_fields
= 4,
347 nr_model_static_fields
= nr_function_fields
,
348 nr_model_internal_fields
= nr_function_fields
,
349 nr_model_function_fields
= nr_function_fields
,
352 typedef struct _model_data model_data
;
364 model_name_field
= 4,
365 model_full_name_field
,
366 model_unit_data_field
,
367 nr_model_processor_fields
,
370 typedef struct _model_entry model_entry
;
382 typedef struct _model_table model_table
;
390 function_entry
*statics
;
391 function_entry
*internals
;
392 function_entry
*functions
;
397 /* Instruction format:
399 An instruction is composed of a sequence of N bit instruction
400 words. Each word broken into a number of instruction fields.
401 Those fields being constant (ex. an opcode) or variable (register
405 <insn-field> { "," <insn-field> } ;
408 ( <binary-value-implying-width>
409 | <field-name-implying-width>
410 | [ <start-or-width> "." ] <field>
412 { [ "!" | "=" ] [ <value> | <field-name> ] }
420 | "0b" <binary-value>
426 typedef enum _insn_field_cond_type
428 insn_field_cond_value
,
429 insn_field_cond_field
,
431 insn_field_cond_type
;
432 typedef enum _insn_field_cond_test
437 insn_field_cond_test
;
438 typedef struct _insn_field_cond insn_field_cond
;
439 struct _insn_field_cond
441 insn_field_cond_type type
;
442 insn_field_cond_test test
;
444 struct _insn_field_entry
*field
;
446 insn_field_cond
*next
;
450 typedef enum _insn_field_type
460 typedef struct _insn_field_entry insn_field_entry
;
461 struct _insn_field_entry
467 insn_field_type type
;
471 insn_field_cond
*conditions
;
472 insn_field_entry
*next
;
473 insn_field_entry
*prev
;
476 typedef struct _insn_bit_entry insn_bit_entry
;
477 struct _insn_bit_entry
481 insn_field_entry
*field
;
487 typedef struct _insn_entry insn_entry
; /* forward */
489 typedef struct _insn_word_entry insn_word_entry
;
490 struct _insn_word_entry
492 /* list of sub-fields making up the instruction. bit provides
493 faster access to the field data for bit N. */
494 insn_field_entry
*first
;
495 insn_field_entry
*last
;
496 insn_bit_entry
*bit
[max_insn_bit_size
];
497 /* set of all the string fields */
499 /* For multi-word instructions, The Nth word (from zero). */
500 insn_word_entry
*next
;
505 /* Instruction model:
507 Provides scheduling and other data for the code modeling the
511 "*" [ <processor-list> ]
512 ":" [ <function-unit-data> ]
517 <processor> { "," <processor>" }
520 If the <processor-list> is empty, the model is made the default for
527 insn_model_name_field
= 0,
528 insn_model_unit_data_field
= 1,
529 nr_insn_model_fields
= 1,
532 typedef struct _insn_model_entry insn_model_entry
;
533 struct _insn_model_entry
540 insn_model_entry
*next
;
545 /* Instruction mnemonic:
547 List of assembler mnemonics for the instruction.
550 "\"" <assembler-mnemonic> "\""
551 [ ":" <conditional-expression> ]
555 An assembler mnemonic string has the syntax:
557 <assembler-mnemonic> ::=
558 ( [ "%" <format-spec> ] "<" <func> [ "#" <param-list> ] ">"
563 Where, for instance, the text is translated into a printf format
566 "<FUNC>" : "%ld", (long) FUNC
567 "%<FUNC>..." : "%...", FUNC
568 "%s<FUNC>" : "%s", <%s>FUNC (SD_, FUNC)
569 "%s<FUNC#P1,P2>" : "%s", <%s>FUNC (SD_, P1,P2)
570 "%lx<FUNC>" : "%lx", (unsigned long) FUNC
571 "%08lx<FUNC>" : "%08lx", (unsigned long) FUNC
573 And "<%s>FUNC" denotes a function declared using the "%s" record
584 insn_mnemonic_format_field
= 0,
585 insn_mnemonic_condition_field
= 1,
586 nr_insn_mnemonic_fields
= 1,
589 typedef struct _insn_mnemonic_entry insn_mnemonic_entry
;
590 struct _insn_mnemonic_entry
596 insn_mnemonic_entry
*next
;
604 <insn-word> { "+" <insn-word> }
619 insn_format_name_field
= 1,
620 insn_filter_flags_field
= 2,
621 insn_options_field
= 3,
627 /* typedef struct _insn_entry insn_entry; */
631 filter
*flags
; /* filtered by options.filters */
635 /* the words that make up the instruction. Word provides direct
636 access to word N. Pseudo instructions can be identified by
639 insn_word_entry
*words
;
640 insn_word_entry
**word
;
641 /* a set of all the fields from all the words */
643 /* an array of processor models, missing models are NULL! */
645 insn_model_entry
*models
;
646 insn_model_entry
**model
;
648 /* list of assember formats */
650 insn_mnemonic_entry
*mnemonics
;
657 /* Instruction table:
661 typedef struct _insn_table insn_table
;
668 function_entry
*functions
;
669 insn_entry
*illegal_insn
;
675 extern insn_table
*load_insn_table (const char *file_name
, cache_entry
*cache
);
677 typedef void insn_entry_handler
678 (lf
*file
, const insn_table
*isa
, const insn_entry
*insn
, void *data
);
680 extern void insn_table_traverse_insn
681 (lf
*file
, const insn_table
*isa
, insn_entry_handler
*handler
, void *data
);
687 extern void print_insn_words (lf
*file
, const insn_entry
*insn
);
694 (lf
*file
, const char *prefix
, const insn_field_entry
*field
,
697 void dump_insn_word_entry
698 (lf
*file
, const char *prefix
, const insn_word_entry
*word
,
702 (lf
*file
, const char *prefix
, const insn_entry
*insn
, const char *suffix
);
704 void dump_cache_entries
705 (lf
*file
, const char *prefix
, const cache_entry
*entry
, const char *suffix
);
708 (lf
*file
, const char *prefix
, const insn_table
*isa
, const char *suffix
);
710 #endif /* IGEN_LD_INSN_H */