1 /* The IGEN simulator generator for GDB, the GNU Debugger.
3 Copyright 2002-2016 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 unsigned64 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, function_entry * function, void *data);
224 extern void function_entry_traverse
226 function_entry * functions, function_entry_handler * handler, void *data);
237 ":" <field-name> { "," <field-name> }
242 <cache-macro-type> ::=
250 | <ident> "_is_" <integer>
253 A cache entry is defined (for an instruction) when all
254 <field-name>s are present as named opcode fields within the
257 SCRATCH and CACHE macros are defined during the cache fill stage
258 while CACHE and COMPUTE macros are defined during the instruction
265 cache_typedef_field = 4,
267 cache_original_fields_field,
268 cache_expression_field,
280 typedef struct _cache_entry cache_entry;
286 cache_entry_type entry_type;
288 filter *original_fields;
298 <model-processor> ::=
304 ":" <function-unit-data>
343 nr_model_macro_fields = 4,
344 nr_model_data_fields = 4,
345 nr_model_static_fields = nr_function_fields,
346 nr_model_internal_fields = nr_function_fields,
347 nr_model_function_fields = nr_function_fields,
350 typedef struct _model_data model_data;
362 model_name_field = 4,
363 model_full_name_field,
364 model_unit_data_field,
365 nr_model_processor_fields,
368 typedef struct _model_entry model_entry;
380 typedef struct _model_table model_table;
388 function_entry *statics;
389 function_entry *internals;
390 function_entry *functions;
395 /* Instruction format:
397 An instruction is composed of a sequence of N bit instruction
398 words. Each word broken into a number of instruction fields.
399 Those fields being constant (ex. an opcode) or variable (register
403 <insn-field> { "," <insn-field> } ;
406 ( <binary-value-implying-width>
407 | <field-name-implying-width>
408 | [ <start-or-width> "." ] <field>
410 { [ "!" | "=" ] [ <value> | <field-name> ] }
418 | "0b" <binary-value>
424 typedef enum _insn_field_cond_type
426 insn_field_cond_value,
427 insn_field_cond_field,
429 insn_field_cond_type;
430 typedef enum _insn_field_cond_test
435 insn_field_cond_test;
436 typedef struct _insn_field_cond insn_field_cond;
437 struct _insn_field_cond
439 insn_field_cond_type type;
440 insn_field_cond_test test;
442 struct _insn_field_entry *field;
444 insn_field_cond *next;
448 typedef enum _insn_field_type
458 typedef struct _insn_field_entry insn_field_entry;
459 struct _insn_field_entry
465 insn_field_type type;
469 insn_field_cond *conditions;
470 insn_field_entry *next;
471 insn_field_entry *prev;
474 typedef struct _insn_bit_entry insn_bit_entry;
475 struct _insn_bit_entry
479 insn_field_entry *field;
485 typedef struct _insn_entry insn_entry; /* forward */
487 typedef struct _insn_word_entry insn_word_entry;
488 struct _insn_word_entry
490 /* list of sub-fields making up the instruction. bit provides
491 faster access to the field data for bit N. */
492 insn_field_entry *first;
493 insn_field_entry *last;
494 insn_bit_entry *bit[max_insn_bit_size];
495 /* set of all the string fields */
497 /* For multi-word instructions, The Nth word (from zero). */
498 insn_word_entry *next;
503 /* Instruction model:
505 Provides scheduling and other data for the code modeling the
509 "*" [ <processor-list> ]
510 ":" [ <function-unit-data> ]
515 <processor> { "," <processor>" }
518 If the <processor-list> is empty, the model is made the default for
525 insn_model_name_field = 0,
526 insn_model_unit_data_field = 1,
527 nr_insn_model_fields = 1,
530 typedef struct _insn_model_entry insn_model_entry;
531 struct _insn_model_entry
538 insn_model_entry *next;
543 /* Instruction mnemonic:
545 List of assembler mnemonics for the instruction.
548 "\"" <assembler-mnemonic> "\""
549 [ ":" <conditional-expression> ]
553 An assembler mnemonic string has the syntax:
555 <assembler-mnemonic> ::=
556 ( [ "%" <format-spec> ] "<" <func> [ "#" <param-list> ] ">"
561 Where, for instance, the text is translated into a printf format
564 "<FUNC>" : "%ld", (long) FUNC
565 "%<FUNC>..." : "%...", FUNC
566 "%s<FUNC>" : "%s", <%s>FUNC (SD_, FUNC)
567 "%s<FUNC#P1,P2>" : "%s", <%s>FUNC (SD_, P1,P2)
568 "%lx<FUNC>" : "%lx", (unsigned long) FUNC
569 "%08lx<FUNC>" : "%08lx", (unsigned long) FUNC
571 And "<%s>FUNC" denotes a function declared using the "%s" record
582 insn_mnemonic_format_field = 0,
583 insn_mnemonic_condition_field = 1,
584 nr_insn_mnemonic_fields = 1,
587 typedef struct _insn_mnemonic_entry insn_mnemonic_entry;
588 struct _insn_mnemonic_entry
594 insn_mnemonic_entry *next;
602 <insn-word> { "+" <insn-word> }
617 insn_format_name_field = 1,
618 insn_filter_flags_field = 2,
619 insn_options_field = 3,
625 /* typedef struct _insn_entry insn_entry; */
629 filter *flags; /* filtered by options.filters */
633 /* the words that make up the instruction. Word provides direct
634 access to word N. Pseudo instructions can be identified by
637 insn_word_entry *words;
638 insn_word_entry **word;
639 /* a set of all the fields from all the words */
641 /* an array of processor models, missing models are NULL! */
643 insn_model_entry *models;
644 insn_model_entry **model;
646 /* list of assember formats */
648 insn_mnemonic_entry *mnemonics;
655 /* Instruction table:
659 typedef struct _insn_table insn_table;
666 function_entry *functions;
667 insn_entry *illegal_insn;
673 extern insn_table *load_insn_table (char *file_name, cache_entry *cache);
675 typedef void insn_entry_handler
676 (lf *file, insn_table *isa, insn_entry * insn, void *data);
678 extern void insn_table_traverse_insn
679 (lf *file, insn_table *isa, insn_entry_handler * handler, void *data);
685 extern void print_insn_words (lf *file, insn_entry * insn);
693 (lf *file, char *prefix, insn_field_entry *field, char *suffix);
697 (lf *file, char *prefix, insn_word_entry *word, char *suffix);
700 dump_insn_entry (lf *file, char *prefix, insn_entry * insn, char *suffix);
704 (lf *file, char *prefix, cache_entry *entry, char *suffix);
706 void dump_insn_table (lf *file, char *prefix, insn_table *isa, char *suffix);