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 3 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, see <http://www.gnu.org/licenses/>.
20 /* Instruction decode table:
22 <options>:<first>:<last>:<force-first>:<force-last>:<force-expand>:<special>...
29 The instruction decode table contains rules that dictate how igen
30 is going to firstly break down the opcode table and secondly
32 The table that follows is used by gen to construct a decision tree
33 that can identify each possible instruction. Gen then outputs this
34 decision tree as (according to config) a table or switch statement
35 as the function idecode.
37 In parallel to this, as mentioned above, WITH_EXPANDED_SEMANTICS
38 determines of the semantic functions themselves should be expanded
44 Range of bits (within the instruction) that should be searched for
45 an instruction field. Within such ranges, gen looks for opcodes
46 (constants), registers (strings) and reserved bits (slash) and
47 according to the rules that follows includes or excludes them from
48 a possible instruction field.
53 If an instruction field was found, enlarge the field size so that
54 it is forced to at least include bits starting from <force_first>
55 (<force_last>). To stop this occuring, use <force_first> = <last>
56 + 1 and <force_last> = <first> - 1.
60 Treat `/' fields as a constant instead of variable when looking for
65 Treat any contained register (string) fields as constant when
66 determining the instruction field. For the instruction decode (and
67 controled by IDECODE_EXPAND_SEMANTICS) this forces the expansion of
68 what would otherwize be non constant bits of an instruction.
72 Should this table be expanded using a switch statement (val 1) and
73 if so, should it be padded with entries so as to force the compiler
74 to generate a jump table (val 2). Or a branch table (val 3).
81 Special rule to fine tune how specific (or groups) of instructions
82 are expanded. The applicability of the rule is determined by
84 <special_mask> != 0 && (instruction> & <special_mask>) == <special_value>
86 Where <instruction> is obtained by looking only at constant fields
87 with in an instructions spec. When determining an expansion, the
88 rule is only considered when a node contains a single instruction.
89 <special_rule> can be any of:
91 0: for this instruction, expand by earlier rules
92 1: expand bits <force_low> .. <force_hi> only
93 2: boolean expansion of only zero/non-zero cases
94 3: boolean expansion of equality of special constant
104 } decode_special_type
;
116 typedef struct _decode_table decode_table
;
117 struct _decode_table
{
118 decode_special_type type
;
125 char *force_expansion
;
126 unsigned special_mask
;
127 unsigned special_value
;
128 unsigned special_constant
;
133 extern void force_decode_gen_type
136 extern decode_table
*load_decode_table
137 (const char *file_name
,
140 extern void dump_decode_rule