1 /* This file is part of the program psim.
3 Copyright (C) 1994,1995,1996, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 /* Instruction decode table:
29 ":" [ <constant-field-names> ]
31 ":" [ <format-names> ]
34 ":" [ <path> { "," <path> } ]
36 ":" [ "!" ] <special-value>
42 <path> ::= <int> "," <int> ;;
53 <reserved-options> ::= "zero-reserved" ;
54 <gen-options> ::= "array" | "switch" | "padded-switch" | "goto-switch" ;
55 <optimize-options> ::= "duplicate" | "combine"
56 <decode-options> ::= "normal" | "boolean" ;
57 <search-options> ::= "constants" | "variables" | "mixed"
62 The instruction decode table contains rules that dictate how igen
63 is going to firstly break down the opcode table and secondly
65 The table that follows is used by gen to construct a decision tree
66 that can identify each possible instruction. Gen then outputs this
67 decision tree as (according to config) a table or switch statement
68 as the function idecode.
70 In parallel to this, as mentioned above, WITH_EXPANDED_SEMANTICS
71 determines of the semantic functions themselves should be expanded
77 Range of bits (within the instruction) that should be searched for
78 an instruction field. Within such ranges, gen looks for opcodes
79 (constants), registers (strings) and reserved bits (slash) and
80 according to the rules that follows includes or excludes them from
81 a possible instruction field.
86 If an instruction field was found, enlarge the field size so that
87 it is forced to at least include bits starting from <force_first>
88 (<force_last>). To stop this occuring, use <force_first> = <last>
89 + 1 and <force_last> = <first> - 1.
93 Treat `/' (reserved) fields as a constant (zero) instead of
94 variable when looking for an instruction field.
98 Treat any contained register (string) fields as constant when
99 determining the instruction field. For the instruction decode (and
100 controled by IDECODE_EXPAND_SEMANTICS) this forces the expansion of
101 what would otherwize be non constant bits of an instruction.
105 Should this table be expanded using a switch statement (val 1) and
106 if so, should it be padded with entries so as to force the compiler
107 to generate a jump table (val 2). Or a branch table (val 3).
114 Special rule to fine tune how specific (or groups) of instructions
115 are expanded. The applicability of the rule is determined by
117 <special_mask> != 0 && (instruction> & <special_mask>) == <special_value>
119 Where <instruction> is obtained by looking only at constant fields
120 with in an instructions spec. When determining an expansion, the
121 rule is only considered when a node contains a single instruction.
122 <special_rule> can be any of:
124 0: for this instruction, expand by earlier rules
125 1: expand bits <force_low> .. <force_hi> only
126 2: boolean expansion of only zero/non-zero cases
127 3: boolean expansion of equality of special constant
135 } decode_special_type
;
148 decode_cond_mask_field
,
149 decode_cond_value_field
,
150 decode_cond_word_nr_field
,
151 nr_decode_cond_fields
,
154 typedef struct _decode_path decode_path
;
155 struct _decode_path
{
160 typedef struct _decode_path_list decode_path_list
;
161 struct _decode_path_list
{
163 decode_path_list
*next
;
167 typedef struct _decode_cond decode_cond
;
168 struct _decode_cond
{
170 int mask
[max_insn_bit_size
];
171 int value
[max_insn_bit_size
];
178 decode_find_constants
,
180 } decode_search_type
;
183 decode_options_field
,
186 decode_force_first_field
,
187 decode_force_last_field
,
188 decode_constant_field_names_field
,
189 decode_word_nr_field
,
190 decode_format_names_field
,
191 decode_model_names_field
,
194 min_nr_decode_fields
= decode_last_field
+ 1,
198 typedef struct _decode_table decode_table
;
199 struct _decode_table
{
201 decode_special_type type
;
203 decode_search_type search
;
208 filter
*constant_field_names
;
213 int with_zero_reserved
;
216 /* conditions on the rule being applied */
217 decode_path_list
*paths
;
218 filter
*format_names
;
220 decode_cond
*conditions
;
225 extern decode_table
*load_decode_table
228 extern int decode_table_max_word_nr
229 (decode_table
*rule
);
231 extern void dump_decode_rule