Home | History | Annotate | Line # | Download | only in igen
      1       1.1  christos /* The IGEN simulator generator for GDB, the GNU Debugger.
      2       1.1  christos 
      3  1.1.1.10  christos    Copyright 2002-2024 Free Software Foundation, Inc.
      4       1.1  christos 
      5       1.1  christos    Contributed by Andrew Cagney.
      6       1.1  christos 
      7       1.1  christos    This file is part of GDB.
      8       1.1  christos 
      9       1.1  christos    This program is free software; you can redistribute it and/or modify
     10       1.1  christos    it under the terms of the GNU General Public License as published by
     11       1.1  christos    the Free Software Foundation; either version 3 of the License, or
     12       1.1  christos    (at your option) any later version.
     13       1.1  christos 
     14       1.1  christos    This program is distributed in the hope that it will be useful,
     15       1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     16       1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17       1.1  christos    GNU General Public License for more details.
     18       1.1  christos 
     19       1.1  christos    You should have received a copy of the GNU General Public License
     20       1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     21       1.1  christos 
     22  1.1.1.10  christos #ifndef IGEN_LD_DECODE_H
     23  1.1.1.10  christos #define IGEN_LD_DECODE_H
     24       1.1  christos 
     25       1.1  christos /* Instruction decode table:
     26       1.1  christos 
     27       1.1  christos    <decode-rule> ::=
     28       1.1  christos        { <option> }
     29       1.1  christos        ":" [ <first> ]
     30       1.1  christos        ":" [ <last> ]
     31       1.1  christos        ":" [ <force-first> ]
     32       1.1  christos        ":" [ <force-last> ]
     33       1.1  christos        ":" [ <constant-field-names> ]
     34       1.1  christos        ":" [ <word-nr> ]
     35       1.1  christos        ":" [ <format-names> ]
     36       1.1  christos        ":" [ <model-names> ]
     37       1.1  christos        ":" [ <constant> ]
     38       1.1  christos        ":" [ <path> { "," <path> } ]
     39       1.1  christos        { ":" <special-mask>
     40       1.1  christos          ":" [ "!" ] <special-value>
     41       1.1  christos          ":" <word-nr> }
     42       1.1  christos        <nl>
     43       1.1  christos        ;
     44       1.1  christos 
     45       1.1  christos 
     46       1.1  christos    <path> ::= <int> "," <int> ;;
     47       1.1  christos 
     48       1.1  christos    <option> ::=
     49       1.1  christos        <reserved-options>
     50       1.1  christos        | <code-options>
     51       1.1  christos        | <optimize-options>
     52       1.1  christos        | <decode-options>
     53       1.1  christos        | <constant>
     54       1.1  christos        | <search-options>
     55       1.1  christos        ;
     56       1.1  christos 
     57       1.1  christos    <reserved-options> ::= "zero-reserved" ;
     58       1.1  christos    <gen-options> ::= "array" | "switch" | "padded-switch" | "goto-switch" ;
     59       1.1  christos    <optimize-options> ::= "duplicate" | "combine"
     60       1.1  christos    <decode-options> ::= "normal" | "boolean" ;
     61       1.1  christos    <search-options> ::= "constants" | "variables" | "mixed"
     62       1.1  christos 
     63       1.1  christos    Ignore the below:
     64       1.1  christos 
     65       1.1  christos 
     66       1.1  christos    The instruction decode table contains rules that dictate how igen
     67       1.1  christos    is going to firstly break down the opcode table and secondly
     68       1.1  christos 
     69       1.1  christos    The table that follows is used by gen to construct a decision tree
     70       1.1  christos    that can identify each possible instruction.  Gen then outputs this
     71       1.1  christos    decision tree as (according to config) a table or switch statement
     72       1.1  christos    as the function idecode.
     73       1.1  christos 
     74       1.1  christos    In parallel to this, as mentioned above, WITH_EXPANDED_SEMANTICS
     75       1.1  christos    determines of the semantic functions themselves should be expanded
     76       1.1  christos    in a similar way.
     77       1.1  christos 
     78       1.1  christos    <first>
     79       1.1  christos    <last>
     80       1.1  christos 
     81       1.1  christos    Range of bits (within the instruction) that should be searched for
     82       1.1  christos    an instruction field.  Within such ranges, gen looks for opcodes
     83       1.1  christos    (constants), registers (strings) and reserved bits (slash) and
     84       1.1  christos    according to the rules that follows includes or excludes them from
     85       1.1  christos    a possible instruction field.
     86       1.1  christos 
     87       1.1  christos    <force_first>
     88       1.1  christos    <force_last>
     89       1.1  christos 
     90       1.1  christos    If an instruction field was found, enlarge the field size so that
     91       1.1  christos    it is forced to at least include bits starting from <force_first>
     92  1.1.1.11  christos    (<force_last>).  To stop this occurring, use <force_first> = <last>
     93       1.1  christos    + 1 and <force_last> = <first> - 1.
     94       1.1  christos 
     95       1.1  christos    <force_reserved>
     96       1.1  christos 
     97       1.1  christos    Treat `/' (reserved) fields as a constant (zero) instead of
     98       1.1  christos    variable when looking for an instruction field.
     99       1.1  christos 
    100       1.1  christos    <force_expansion>
    101       1.1  christos 
    102       1.1  christos    Treat any contained register (string) fields as constant when
    103       1.1  christos    determining the instruction field.  For the instruction decode (and
    104  1.1.1.11  christos    controlled by IDECODE_EXPAND_SEMANTICS) this forces the expansion of
    105       1.1  christos    what would otherwize be non constant bits of an instruction.
    106       1.1  christos 
    107       1.1  christos    <use_switch>
    108       1.1  christos 
    109       1.1  christos    Should this table be expanded using a switch statement (val 1) and
    110       1.1  christos    if so, should it be padded with entries so as to force the compiler
    111       1.1  christos    to generate a jump table (val 2). Or a branch table (val 3).
    112       1.1  christos 
    113       1.1  christos    <special_mask>
    114       1.1  christos    <special_value>
    115       1.1  christos    <special_rule>
    116       1.1  christos    <special_constant>
    117       1.1  christos 
    118       1.1  christos    Special rule to fine tune how specific (or groups) of instructions
    119       1.1  christos    are expanded.  The applicability of the rule is determined by
    120       1.1  christos 
    121       1.1  christos      <special_mask> != 0 && (instruction> & <special_mask>) == <special_value>
    122       1.1  christos 
    123       1.1  christos    Where <instruction> is obtained by looking only at constant fields
    124       1.1  christos    with in an instructions spec.  When determining an expansion, the
    125       1.1  christos    rule is only considered when a node contains a single instruction.
    126       1.1  christos    <special_rule> can be any of:
    127       1.1  christos 
    128       1.1  christos         0: for this instruction, expand by earlier rules
    129       1.1  christos    	1: expand bits <force_low> .. <force_hi> only
    130       1.1  christos 	2: boolean expansion of only zero/non-zero cases
    131       1.1  christos 	3: boolean expansion of equality of special constant
    132       1.1  christos 
    133       1.1  christos 	*/
    134       1.1  christos 
    135       1.1  christos 
    136       1.1  christos typedef enum
    137       1.1  christos {
    138       1.1  christos   normal_decode_rule,
    139       1.1  christos   boolean_rule,
    140       1.1  christos }
    141       1.1  christos decode_special_type;
    142       1.1  christos 
    143       1.1  christos 
    144       1.1  christos typedef enum
    145       1.1  christos {
    146       1.1  christos   invalid_gen,
    147       1.1  christos   array_gen,
    148       1.1  christos   switch_gen,
    149       1.1  christos   padded_switch_gen,
    150       1.1  christos   goto_switch_gen,
    151       1.1  christos }
    152       1.1  christos decode_gen_type;
    153       1.1  christos 
    154       1.1  christos 
    155       1.1  christos enum
    156       1.1  christos {
    157       1.1  christos   decode_cond_mask_field,
    158       1.1  christos   decode_cond_value_field,
    159       1.1  christos   decode_cond_word_nr_field,
    160       1.1  christos   nr_decode_cond_fields,
    161       1.1  christos };
    162       1.1  christos 
    163       1.1  christos typedef struct _decode_path decode_path;
    164       1.1  christos struct _decode_path
    165       1.1  christos {
    166       1.1  christos   int opcode_nr;
    167       1.1  christos   decode_path *parent;
    168       1.1  christos };
    169       1.1  christos 
    170       1.1  christos typedef struct _decode_path_list decode_path_list;
    171       1.1  christos struct _decode_path_list
    172       1.1  christos {
    173       1.1  christos   decode_path *path;
    174       1.1  christos   decode_path_list *next;
    175       1.1  christos };
    176       1.1  christos 
    177       1.1  christos 
    178       1.1  christos typedef struct _decode_cond decode_cond;
    179       1.1  christos struct _decode_cond
    180       1.1  christos {
    181       1.1  christos   int word_nr;
    182       1.1  christos   int mask[max_insn_bit_size];
    183       1.1  christos   int value[max_insn_bit_size];
    184       1.1  christos   int is_equal;
    185       1.1  christos   decode_cond *next;
    186       1.1  christos };
    187       1.1  christos 
    188       1.1  christos typedef enum
    189       1.1  christos {
    190       1.1  christos   decode_find_mixed,
    191       1.1  christos   decode_find_constants,
    192       1.1  christos   decode_find_strings,
    193       1.1  christos }
    194       1.1  christos decode_search_type;
    195       1.1  christos 
    196       1.1  christos enum
    197       1.1  christos {
    198       1.1  christos   decode_options_field,
    199       1.1  christos   decode_first_field,
    200       1.1  christos   decode_last_field,
    201       1.1  christos   decode_force_first_field,
    202       1.1  christos   decode_force_last_field,
    203       1.1  christos   decode_constant_field_names_field,
    204       1.1  christos   decode_word_nr_field,
    205       1.1  christos   decode_format_names_field,
    206       1.1  christos   decode_model_names_field,
    207       1.1  christos   decode_paths_field,
    208       1.1  christos   nr_decode_fields,
    209       1.1  christos   min_nr_decode_fields = decode_last_field + 1,
    210       1.1  christos };
    211       1.1  christos 
    212       1.1  christos 
    213       1.1  christos typedef struct _decode_table decode_table;
    214       1.1  christos struct _decode_table
    215       1.1  christos {
    216       1.1  christos   line_ref *line;
    217       1.1  christos   decode_special_type type;
    218       1.1  christos   decode_gen_type gen;
    219       1.1  christos   decode_search_type search;
    220       1.1  christos   int first;
    221       1.1  christos   int last;
    222       1.1  christos   int force_first;
    223       1.1  christos   int force_last;
    224       1.1  christos   filter *constant_field_names;
    225       1.1  christos   int word_nr;
    226       1.1  christos   /* if a boolean */
    227       1.1  christos   unsigned constant;
    228       1.1  christos   /* options */
    229       1.1  christos   int with_zero_reserved;
    230       1.1  christos   int with_duplicates;
    231       1.1  christos   int with_combine;
    232       1.1  christos   /* conditions on the rule being applied */
    233       1.1  christos   decode_path_list *paths;
    234       1.1  christos   filter *format_names;
    235       1.1  christos   filter *model_names;
    236       1.1  christos   decode_cond *conditions;
    237       1.1  christos   decode_table *next;
    238       1.1  christos };
    239       1.1  christos 
    240       1.1  christos 
    241   1.1.1.9  christos extern decode_table *load_decode_table (const char *file_name);
    242       1.1  christos 
    243   1.1.1.9  christos extern int decode_table_max_word_nr (const decode_table *rule);
    244       1.1  christos 
    245       1.1  christos extern void dump_decode_rule
    246   1.1.1.9  christos   (lf *file, const char *prefix, const decode_table *rule, const char *suffix);
    247  1.1.1.10  christos 
    248  1.1.1.10  christos #endif /* IGEN_LD_DECODE_H */
    249