Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994,1995,1996, Andrew Cagney <cagney@highland.com.au> | |
4 | ||
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 | |
3fd725ef | 7 | the Free Software Foundation; either version 3 of the License, or |
c906108c SS |
8 | (at your option) any later version. |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
51b318de | 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
17 | |
18 | */ | |
19 | ||
20 | /* Instruction decode table: | |
21 | ||
22 | <options>:<first>:<last>:<force-first>:<force-last>:<force-expand>:<special>... | |
23 | ||
24 | ||
25 | ||
26 | Ignore the below: | |
27 | ||
28 | ||
29 | The instruction decode table contains rules that dictate how igen | |
30 | is going to firstly break down the opcode table and secondly | |
31 | ||
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. | |
36 | ||
37 | In parallel to this, as mentioned above, WITH_EXPANDED_SEMANTICS | |
38 | determines of the semantic functions themselves should be expanded | |
39 | in a similar way. | |
40 | ||
41 | <first> | |
42 | <last> | |
43 | ||
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. | |
49 | ||
50 | <force_first> | |
51 | <force_last> | |
52 | ||
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. | |
57 | ||
58 | <force_slash> | |
59 | ||
60 | Treat `/' fields as a constant instead of variable when looking for | |
61 | an instruction field. | |
62 | ||
63 | <force_expansion> | |
64 | ||
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. | |
69 | ||
70 | <use_switch> | |
71 | ||
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). | |
75 | ||
76 | <special_mask> | |
77 | <special_value> | |
78 | <special_rule> | |
79 | <special_constant> | |
80 | ||
81 | Special rule to fine tune how specific (or groups) of instructions | |
82 | are expanded. The applicability of the rule is determined by | |
83 | ||
84 | <special_mask> != 0 && (instruction> & <special_mask>) == <special_value> | |
85 | ||
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: | |
90 | ||
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 | |
95 | ||
96 | */ | |
97 | ||
98 | ||
99 | typedef enum { | |
100 | normal_decode_rule, | |
101 | expand_forced_rule, | |
102 | boolean_rule, | |
103 | nr_decode_rules | |
104 | } decode_special_type; | |
105 | ||
106 | typedef enum { | |
107 | invalid_gen, | |
108 | array_gen, | |
109 | switch_gen, | |
110 | padded_switch_gen, | |
111 | goto_switch_gen, | |
112 | nr_decode_gen_types, | |
113 | } decode_gen_type; | |
114 | ||
115 | ||
116 | typedef struct _decode_table decode_table; | |
117 | struct _decode_table { | |
118 | decode_special_type type; | |
119 | decode_gen_type gen; | |
120 | int first; | |
121 | int last; | |
122 | int force_first; | |
123 | int force_last; | |
124 | int force_slash; | |
125 | char *force_expansion; | |
126 | unsigned special_mask; | |
127 | unsigned special_value; | |
128 | unsigned special_constant; | |
129 | decode_table *next; | |
130 | }; | |
131 | ||
132 | ||
133 | extern void force_decode_gen_type | |
134 | (const char *type); | |
135 | ||
136 | extern decode_table *load_decode_table | |
137 | (char *file_name, | |
138 | int hi_bit_nr); | |
139 | ||
140 | extern void dump_decode_rule | |
141 | (decode_table *rule, | |
142 | int indent); |