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