ld-decode.h 4.1 KB

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