Home | History | Annotate | Line # | Download | only in ppc
      1  1.1  christos /*  This file is part of the program psim.
      2  1.1  christos 
      3  1.1  christos     Copyright (C) 1994,1995,1996, Andrew Cagney <cagney (at) highland.com.au>
      4  1.1  christos 
      5  1.1  christos     This program is free software; you can redistribute it and/or modify
      6  1.1  christos     it under the terms of the GNU General Public License as published by
      7  1.1  christos     the Free Software Foundation; either version 3 of the License, or
      8  1.1  christos     (at your option) any later version.
      9  1.1  christos 
     10  1.1  christos     This program is distributed in the hope that it will be useful,
     11  1.1  christos     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  1.1  christos     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  1.1  christos     GNU General Public License for more details.
     14  1.1  christos 
     15  1.1  christos     You should have received a copy of the GNU General Public License
     16  1.1  christos     along with this program; if not, see <http://www.gnu.org/licenses/>.
     17  1.1  christos 
     18  1.1  christos     */
     19  1.1  christos 
     20  1.1  christos /* Instruction decode table:
     21  1.1  christos 
     22  1.1  christos    <options>:<first>:<last>:<force-first>:<force-last>:<force-expand>:<special>...
     23  1.1  christos 
     24  1.1  christos 
     25  1.1  christos 
     26  1.1  christos    Ignore the below:
     27  1.1  christos 
     28  1.1  christos 
     29  1.1  christos    The instruction decode table contains rules that dictate how igen
     30  1.1  christos    is going to firstly break down the opcode table and secondly
     31  1.1  christos 
     32  1.1  christos    The table that follows is used by gen to construct a decision tree
     33  1.1  christos    that can identify each possible instruction.  Gen then outputs this
     34  1.1  christos    decision tree as (according to config) a table or switch statement
     35  1.1  christos    as the function idecode.
     36  1.1  christos 
     37  1.1  christos    In parallel to this, as mentioned above, WITH_EXPANDED_SEMANTICS
     38  1.1  christos    determines of the semantic functions themselves should be expanded
     39  1.1  christos    in a similar way.
     40  1.1  christos 
     41  1.1  christos    <first>
     42  1.1  christos    <last>
     43  1.1  christos 
     44  1.1  christos    Range of bits (within the instruction) that should be searched for
     45  1.1  christos    an instruction field.  Within such ranges, gen looks for opcodes
     46  1.1  christos    (constants), registers (strings) and reserved bits (slash) and
     47  1.1  christos    according to the rules that follows includes or excludes them from
     48  1.1  christos    a possible instruction field.
     49  1.1  christos 
     50  1.1  christos    <force_first>
     51  1.1  christos    <force_last>
     52  1.1  christos 
     53  1.1  christos    If an instruction field was found, enlarge the field size so that
     54  1.1  christos    it is forced to at least include bits starting from <force_first>
     55  1.1  christos    (<force_last>).  To stop this occuring, use <force_first> = <last>
     56  1.1  christos    + 1 and <force_last> = <first> - 1.
     57  1.1  christos 
     58  1.1  christos    <force_slash>
     59  1.1  christos 
     60  1.1  christos    Treat `/' fields as a constant instead of variable when looking for
     61  1.1  christos    an instruction field.
     62  1.1  christos 
     63  1.1  christos    <force_expansion>
     64  1.1  christos 
     65  1.1  christos    Treat any contained register (string) fields as constant when
     66  1.1  christos    determining the instruction field.  For the instruction decode (and
     67  1.1  christos    controled by IDECODE_EXPAND_SEMANTICS) this forces the expansion of
     68  1.1  christos    what would otherwize be non constant bits of an instruction.
     69  1.1  christos 
     70  1.1  christos    <use_switch>
     71  1.1  christos 
     72  1.1  christos    Should this table be expanded using a switch statement (val 1) and
     73  1.1  christos    if so, should it be padded with entries so as to force the compiler
     74  1.1  christos    to generate a jump table (val 2). Or a branch table (val 3).
     75  1.1  christos 
     76  1.1  christos    <special_mask>
     77  1.1  christos    <special_value>
     78  1.1  christos    <special_rule>
     79  1.1  christos    <special_constant>
     80  1.1  christos 
     81  1.1  christos    Special rule to fine tune how specific (or groups) of instructions
     82  1.1  christos    are expanded.  The applicability of the rule is determined by
     83  1.1  christos 
     84  1.1  christos      <special_mask> != 0 && (instruction> & <special_mask>) == <special_value>
     85  1.1  christos 
     86  1.1  christos    Where <instruction> is obtained by looking only at constant fields
     87  1.1  christos    with in an instructions spec.  When determining an expansion, the
     88  1.1  christos    rule is only considered when a node contains a single instruction.
     89  1.1  christos    <special_rule> can be any of:
     90  1.1  christos 
     91  1.1  christos         0: for this instruction, expand by earlier rules
     92  1.1  christos    	1: expand bits <force_low> .. <force_hi> only
     93  1.1  christos 	2: boolean expansion of only zero/non-zero cases
     94  1.1  christos 	3: boolean expansion of equality of special constant
     95  1.1  christos 
     96  1.1  christos 	*/
     97  1.1  christos 
     98  1.1  christos 
     99  1.1  christos typedef enum {
    100  1.1  christos   normal_decode_rule,
    101  1.1  christos   expand_forced_rule,
    102  1.1  christos   boolean_rule,
    103  1.1  christos   nr_decode_rules
    104  1.1  christos } decode_special_type;
    105  1.1  christos 
    106  1.1  christos typedef enum {
    107  1.1  christos   invalid_gen,
    108  1.1  christos   array_gen,
    109  1.1  christos   switch_gen,
    110  1.1  christos   padded_switch_gen,
    111  1.1  christos   goto_switch_gen,
    112  1.1  christos   nr_decode_gen_types,
    113  1.1  christos } decode_gen_type;
    114  1.1  christos 
    115  1.1  christos 
    116  1.1  christos typedef struct _decode_table decode_table;
    117  1.1  christos struct _decode_table {
    118  1.1  christos   decode_special_type type;
    119  1.1  christos   decode_gen_type gen;
    120  1.1  christos   int first;
    121  1.1  christos   int last;
    122  1.1  christos   int force_first;
    123  1.1  christos   int force_last;
    124  1.1  christos   int force_slash;
    125  1.1  christos   char *force_expansion;
    126  1.1  christos   unsigned special_mask;
    127  1.1  christos   unsigned special_value;
    128  1.1  christos   unsigned special_constant;
    129  1.1  christos   decode_table *next;
    130  1.1  christos };
    131  1.1  christos 
    132  1.1  christos 
    133  1.1  christos extern void force_decode_gen_type
    134  1.1  christos (const char *type);
    135  1.1  christos 
    136  1.1  christos extern decode_table *load_decode_table
    137  1.6  christos (const char *file_name,
    138  1.1  christos  int hi_bit_nr);
    139  1.1  christos 
    140  1.1  christos extern void dump_decode_rule
    141  1.1  christos (decode_table *rule,
    142  1.1  christos  int indent);
    143