This commit was manufactured by cvs2svn to create branch 'gdb_7_0-branch'.
[external/binutils.git] / sim / igen / ld-insn.h
index e5bec1d..99a9afc 100644 (file)
@@ -1,22 +1,23 @@
-/*  This file is part of the program psim.
+/* The IGEN simulator generator for GDB, the GNU Debugger.
 
-    Copyright (C) 1994,1995,1996,1997 Andrew Cagney <cagney@highland.com.au>
+   Copyright 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+   Contributed by Andrew Cagney.
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-    */
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 
@@ -35,7 +36,8 @@ typedef unsigned64 insn_uint;
    
  */
 
-enum {
+enum
+{
   record_type_field = 1,
   old_record_type_field = 2,
   record_filter_flags_field = 2,
@@ -57,7 +59,8 @@ enum {
 
    */
 
-enum {
+enum
+{
   include_filename_field = 4,
   nr_include_fields,
 };
@@ -96,10 +99,11 @@ enum {
        ;
 
 
-   These update the global options structure. */       
+   These update the global options structure. */
 
 
-enum {
+enum
+{
   option_name_field = 4,
   option_value_field,
   nr_option_fields,
@@ -110,19 +114,37 @@ enum {
 /* Macro definitions:
 
    <insn-macro> ::=
-       <expression>
-       ":" ( "define" | "undef" )
+       ":" "define"
        ":" <filter-flags>
        ":" <filter-models>
        ":" <name>
+       ":" <arg-list>
+       ":" <expression>
        <nl>
        ;
 
-   Macro define/undef is currently unimplemented. */
+   <arg-list> ::=
+       [ <name> { "," <arg-list> } ]
+       ;
+
+   */
+
+
+enum
+{
+  macro_name_field = 4,
+  macro_args_field,
+  macro_expr_field,
+  nr_macro_fields,
+};
+
 
 
 /* Functions and internal routins:
 
+   NB: <filter-models> and <function-models> are equivalent.
+
+
    <function> ::=
        ":" "function"
        <function-spec>
@@ -138,6 +160,12 @@ enum {
        <function-spec>
        ;
 
+   <function-model> ::=
+       "*" [ <processor-list> ]
+       ":"
+       <nl>
+       ;
+
    <function-spec> ::=
        ":" <filter-flags>
        ":" <filter-models>
@@ -145,29 +173,39 @@ enum {
        ":" <name>
        [ ":" <parameter-list> ]
        <nl>
+       [ <function-model> ]
        <code-block>
        ;
 
    */
 
-enum {
+enum
+{
   function_typedef_field = 4,
   function_name_field,
   function_param_field,
   nr_function_fields,
 };
 
-enum {
+enum
+{
+  function_model_name_field = 0,
+  nr_function_model_fields = 1,
+};
+
+enum
+{
   old_function_typedef_field = 0,
   old_function_type_field = 2,
   old_function_name_field = 4,
   old_function_param_field = 5,
-  nr_old_function_fields = 5, /* parameter-list is optional */
+  nr_old_function_fields = 5,  /* parameter-list is optional */
 };
 
 
 typedef struct _function_entry function_entry;
-struct _function_entry {
+struct _function_entry
+{
   line_ref *line;
   filter *flags;
   filter *models;
@@ -181,15 +219,11 @@ struct _function_entry {
 
 
 typedef void function_entry_handler
-(lf *file,
- function_entry *function,
- void *data);
+  (lf *file, function_entry * function, void *data);
 
 extern void function_entry_traverse
-(lf *file,
- function_entry *functions,
- function_entry_handler *handler,
- void *data);
+  (lf *file,
+   function_entry * functions, function_entry_handler * handler, void *data);
 
 
 /* cache-macro:
@@ -226,7 +260,8 @@ extern void function_entry_traverse
 
    */
 
-enum {
+enum
+{
   cache_typedef_field = 4,
   cache_name_field,
   cache_original_fields_field,
@@ -234,14 +269,17 @@ enum {
   nr_cache_fields,
 };
 
-typedef enum {
+typedef enum
+{
   scratch_value,
   cache_value,
   compute_value,
-} cache_entry_type;
+}
+cache_entry_type;
 
 typedef struct _cache_entry cache_entry;
-struct _cache_entry {
+struct _cache_entry
+{
   line_ref *line;
   filter *flags;
   filter *models;
@@ -262,7 +300,7 @@ struct _cache_entry {
        ":" <filter-flags>
        ":" <filter-models>
        ":" <processor>
-       ":" <long-processor>
+       ":" <BFD-processor>
        ":" <function-unit-data>
        <nl>
        ;
@@ -300,7 +338,8 @@ struct _cache_entry {
 
  */
 
-enum {
+enum
+{
   nr_model_macro_fields = 4,
   nr_model_data_fields = 4,
   nr_model_static_fields = nr_function_fields,
@@ -309,7 +348,8 @@ enum {
 };
 
 typedef struct _model_data model_data;
-struct _model_data {
+struct _model_data
+{
   line_ref *line;
   filter *flags;
   table_entry *entry;
@@ -317,7 +357,8 @@ struct _model_data {
   model_data *next;
 };
 
-enum {
+enum
+{
   model_name_field = 4,
   model_full_name_field,
   model_unit_data_field,
@@ -325,7 +366,8 @@ enum {
 };
 
 typedef struct _model_entry model_entry;
-struct _model_entry {
+struct _model_entry
+{
   line_ref *line;
   filter *flags;
   char *name;
@@ -336,7 +378,8 @@ struct _model_entry {
 
 
 typedef struct _model_table model_table;
-struct _model_table {
+struct _model_table
+{
   filter *processors;
   int nr_models;
   model_entry *models;
@@ -359,17 +402,17 @@ struct _model_table {
    <insn-word> ::=
        <insn-field> { "," <insn-field> } ;
 
-   <insn-word> ::=
+   <insn-field> ::=
        ( <binary-value-implying-width>
        | <field-name-implying-width>
        | [ <start-or-width> "." ] <field> 
        )
-       { "!" <excluded-value> }
+       { [ "!" | "=" ] [ <value> | <field-name> ] }
        ;
 
    <field> ::=
-       "*" +
-       | "/" +
+         { "*" }+
+       | { "/" }+
        | <field-name>
        | "0x" <hex-value>
        | "0b" <binary-value>
@@ -378,22 +421,43 @@ struct _model_table {
 
 */
 
-typedef struct _insn_field_exclusion insn_field_exclusion;
-struct _insn_field_exclusion {
-  char *string;
+typedef enum _insn_field_cond_type
+{
+  insn_field_cond_value,
+  insn_field_cond_field,
+}
+insn_field_cond_type;
+typedef enum _insn_field_cond_test
+{
+  insn_field_cond_eq,
+  insn_field_cond_ne,
+}
+insn_field_cond_test;
+typedef struct _insn_field_cond insn_field_cond;
+struct _insn_field_cond
+{
+  insn_field_cond_type type;
+  insn_field_cond_test test;
   insn_uint value;
-  insn_field_exclusion *next;
+  struct _insn_field_entry *field;
+  char *string;
+  insn_field_cond *next;
 };
 
-typedef enum {
+
+typedef enum _insn_field_type
+{
+  insn_field_invalid,
   insn_field_int,
   insn_field_reserved,
   insn_field_wild,
   insn_field_string,
-} insn_field_type;
+}
+insn_field_type;
 
 typedef struct _insn_field_entry insn_field_entry;
-struct _insn_field_entry {
+struct _insn_field_entry
+{
   int first;
   int last;
   int width;
@@ -402,13 +466,14 @@ struct _insn_field_entry {
   insn_uint val_int;
   char *pos_string;
   char *val_string;
-  insn_field_exclusion *exclusions;
+  insn_field_cond *conditions;
   insn_field_entry *next;
   insn_field_entry *prev;
 };
 
 typedef struct _insn_bit_entry insn_bit_entry;
-struct _insn_bit_entry {
+struct _insn_bit_entry
+{
   int value;
   int mask;
   insn_field_entry *field;
@@ -417,10 +482,11 @@ struct _insn_bit_entry {
 
 
 
-typedef struct _insn_entry insn_entry; /* forward */
+typedef struct _insn_entry insn_entry; /* forward */
 
 typedef struct _insn_word_entry insn_word_entry;
-struct _insn_word_entry {
+struct _insn_word_entry
+{
   /* list of sub-fields making up the instruction.  bit provides
      faster access to the field data for bit N.  */
   insn_field_entry *first;
@@ -436,30 +502,37 @@ struct _insn_word_entry {
 
 /* Instruction model:
 
-   Provides scheduling data for the code modeling the instruction unit. 
+   Provides scheduling and other data for the code modeling the
+   instruction unit.
 
    <insn-model> ::=
-       "*" [ <processor> ]
-       ":" <function-unit-data>
+       "*" [ <processor-list> ]
+       ":" [ <function-unit-data> ]
        <nl>
        ;
 
-   If <processor> is NULL, the model is made the default for this
-   instruction.
+   <processor-list> ::=
+       <processor> { "," <processor>" }
+       ;
+
+   If the <processor-list> is empty, the model is made the default for
+   this instruction.
 
    */
 
-enum {
+enum
+{
   insn_model_name_field = 0,
   insn_model_unit_data_field = 1,
   nr_insn_model_fields = 1,
 };
 
 typedef struct _insn_model_entry insn_model_entry;
-struct _insn_model_entry {
+struct _insn_model_entry
+{
   line_ref *line;
   insn_entry *insn;
-  char *name;
+  filter *names;
   char *full_name;
   char *unit_data;
   insn_model_entry *next;
@@ -477,16 +550,43 @@ struct _insn_model_entry {
        <nl>
        ;
 
+   An assembler mnemonic string has the syntax:
+
+   <assembler-mnemonic>  ::=
+       ( [ "%" <format-spec> ] "<" <func> [ "#" <param-list> ] ">"
+       | "%%"
+       | <other-letter>
+       )+
+
+    Where, for instance, the text is translated into a printf format
+    and argument pair:
+
+       "<FUNC>"         : "%ld", (long) FUNC
+       "%<FUNC>..."     : "%...", FUNC
+       "%s<FUNC>"       : "%s", <%s>FUNC (SD_, FUNC)
+       "%s<FUNC#P1,P2>" : "%s", <%s>FUNC (SD_, P1,P2)
+       "%lx<FUNC>"      : "%lx", (unsigned long) FUNC
+       "%08lx<FUNC>"    : "%08lx", (unsigned long) FUNC
+
+    And "<%s>FUNC" denotes a function declared using the "%s" record
+    specifier.
+
+
+
+       ;
+
    */
 
-enum {
+enum
+{
   insn_mnemonic_format_field = 0,
   insn_mnemonic_condition_field = 1,
   nr_insn_mnemonic_fields = 1,
 };
 
 typedef struct _insn_mnemonic_entry insn_mnemonic_entry;
-struct _insn_mnemonic_entry {
+struct _insn_mnemonic_entry
+{
   line_ref *line;
   insn_entry *insn;
   char *format;
@@ -511,7 +611,8 @@ struct _insn_mnemonic_entry {
 
  */
 
-enum {
+enum
+{
   insn_word_field = 0,
   insn_format_name_field = 1,
   insn_filter_flags_field = 2,
@@ -522,9 +623,10 @@ enum {
 
 
 /* typedef struct _insn_entry insn_entry; */
-struct _insn_entry {
+struct _insn_entry
+{
   line_ref *line;
-  filter *flags; /* filtered by options.filters */
+  filter *flags;               /* filtered by options.filters */
   char *format_name;
   filter *options;
   char *name;
@@ -555,7 +657,8 @@ struct _insn_entry {
  */
 
 typedef struct _insn_table insn_table;
-struct _insn_table {
+struct _insn_table
+{
   cache_entry *caches;
   int max_nr_words;
   int nr_insns;
@@ -567,65 +670,37 @@ struct _insn_table {
   filter *flags;
 };
 
-extern insn_table *load_insn_table
-(char *file_name,
- cache_entry *cache);
+extern insn_table *load_insn_table (char *file_name, cache_entry *cache);
 
 typedef void insn_entry_handler
-(lf *file,
- insn_table *isa,
- insn_entry *insn,
- void *data);
+  (lf *file, insn_table *isa, insn_entry * insn, void *data);
 
 extern void insn_table_traverse_insn
-(lf *file,
- insn_table *isa,
- insn_entry_handler *handler,
- void *data);
+  (lf *file, insn_table *isa, insn_entry_handler * handler, void *data);
 
 
 
 /* Printing */
 
-extern void print_insn_words
-(lf *file,
- insn_entry *insn);
+extern void print_insn_words (lf *file, insn_entry * insn);
 
 
 
 /* Debugging */
 
 void
-dump_insn_field
-(lf *file,
- char *prefix,
- insn_field_entry *field,
- char *suffix);
+  dump_insn_field
+  (lf *file, char *prefix, insn_field_entry *field, char *suffix);
 
 void
-dump_insn_word_entry
-(lf *file,
- char *prefix,
- insn_word_entry *word,
- char *suffix);
+  dump_insn_word_entry
+  (lf *file, char *prefix, insn_word_entry *word, char *suffix);
 
 void
-dump_insn_entry
-(lf *file,
- char *prefix,
- insn_entry *insn,
- char *suffix);
+  dump_insn_entry (lf *file, char *prefix, insn_entry * insn, char *suffix);
 
 void
-dump_cache_entries
-(lf *file,
- char *prefix,
- cache_entry *entry,
- char *suffix);
+  dump_cache_entries
+  (lf *file, char *prefix, cache_entry *entry, char *suffix);
 
-void
-dump_insn_table
-(lf *file,
- char *prefix,
- insn_table *isa,
- char *suffix);
+void dump_insn_table (lf *file, char *prefix, insn_table *isa, char *suffix);