1 /* The IGEN simulator generator for GDB, the GNU Debugger.
3 Copyright 2002 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 2 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, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
26 typedef unsigned64 insn_uint;
29 /* Common among most entries:
31 All non instruction records have the format:
43 record_type_field = 1,
44 old_record_type_field = 2,
45 record_filter_flags_field = 2,
46 record_filter_models_field = 3,
52 Include the specified file.
66 include_filename_field = 4,
74 Valid options are: hi-bit-nr (default 0), insn-bit-size (default
75 32), insn-specifying-widths (default true), multi-sim (default false).
88 | "insn-specifying-widths"
104 These update the global options structure. */
109 option_name_field = 4,
116 /* Macro definitions:
129 [ <name> { "," <arg-list> } ]
137 macro_name_field = 4,
145 /* Functions and internal routins:
147 NB: <filter-models> and <function-models> are equivalent.
166 "*" [ <processor-list> ]
176 [ ":" <parameter-list> ]
186 function_typedef_field = 4,
188 function_param_field,
194 function_model_name_field = 0,
195 nr_function_model_fields = 1,
200 old_function_typedef_field = 0,
201 old_function_type_field = 2,
202 old_function_name_field = 4,
203 old_function_param_field = 5,
204 nr_old_function_fields = 5, /* parameter-list is optional */
208 typedef struct _function_entry function_entry;
209 struct _function_entry
219 function_entry *next;
223 typedef void function_entry_handler
224 (lf *file, function_entry * function, void *data);
226 extern void function_entry_traverse
228 function_entry * functions, 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 (char *file_name, cache_entry *cache);
677 typedef void insn_entry_handler
678 (lf *file, insn_table *isa, insn_entry * insn, void *data);
680 extern void insn_table_traverse_insn
681 (lf *file, insn_table *isa, insn_entry_handler * handler, void *data);
687 extern void print_insn_words (lf *file, insn_entry * insn);
695 (lf *file, char *prefix, insn_field_entry *field, char *suffix);
699 (lf *file, char *prefix, insn_word_entry *word, char *suffix);
702 dump_insn_entry (lf *file, char *prefix, insn_entry * insn, char *suffix);
706 (lf *file, char *prefix, cache_entry *entry, char *suffix);
708 void dump_insn_table (lf *file, char *prefix, insn_table *isa, char *suffix);