igen.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /* The IGEN simulator generator for GDB, the GNU Debugger.
  2. Copyright 2002-2022 Free Software Foundation, Inc.
  3. Contributed by Andrew Cagney.
  4. This file is part of GDB.
  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.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /* code-generation options: */
  16. typedef enum
  17. {
  18. /* Transfer control to an instructions semantic code using the the
  19. standard call/return mechanism */
  20. generate_calls,
  21. /* Transfer control to an instructions semantic code using
  22. (computed) goto's instead of the more conventional call/return
  23. mechanism */
  24. generate_jumps,
  25. }
  26. igen_code;
  27. typedef enum
  28. {
  29. nia_is_cia_plus_one,
  30. nia_is_void,
  31. nia_is_invalid,
  32. }
  33. igen_nia;
  34. typedef struct _igen_gen_options igen_gen_options;
  35. struct _igen_gen_options
  36. {
  37. int direct_access;
  38. int semantic_icache;
  39. int insn_in_icache;
  40. int conditional_issue;
  41. int slot_verification;
  42. int delayed_branch;
  43. /* If zeroing a register, which one? */
  44. int zero_reg;
  45. int zero_reg_nr;
  46. /* should multiple simulators be generated? */
  47. int multi_sim;
  48. /* name of the default multi-sim model */
  49. char *default_model;
  50. /* should the simulator support multi word instructions and if so,
  51. what is the max nr of words. */
  52. int multi_word;
  53. /* SMP? Should the generated code include SMP support (>0) and if
  54. so, for how many processors? */
  55. int smp;
  56. /* how should the next instruction address be computed? */
  57. igen_nia nia;
  58. /* nr of instructions in the decoded instruction cache */
  59. int icache;
  60. int icache_size;
  61. /* see above */
  62. igen_code code;
  63. };
  64. typedef struct _igen_trace_options igen_trace_options;
  65. struct _igen_trace_options
  66. {
  67. int rule_selection;
  68. int rule_rejection;
  69. int insn_insertion;
  70. int insn_expansion;
  71. int entries;
  72. int combine;
  73. };
  74. typedef struct _igen_name
  75. {
  76. char *u;
  77. char *l;
  78. }
  79. igen_name;
  80. typedef struct _igen_module
  81. {
  82. igen_name prefix;
  83. igen_name suffix;
  84. }
  85. igen_module;
  86. typedef struct _igen_module_options
  87. {
  88. igen_module global;
  89. igen_module engine;
  90. igen_module icache;
  91. igen_module idecode;
  92. igen_module itable;
  93. igen_module semantics;
  94. igen_module support;
  95. }
  96. igen_module_options;
  97. typedef struct _igen_decode_options igen_decode_options;
  98. struct _igen_decode_options
  99. {
  100. /* Combine tables? Should the generator make a second pass through
  101. each generated table looking for any sub-entries that contain the
  102. same instructions. Those entries being merged into a single
  103. table */
  104. int combine;
  105. /* Instruction expansion? Should the semantic code for each
  106. instruction, when the oportunity arrises, be expanded according
  107. to the variable opcode files that the instruction decode process
  108. renders constant */
  109. int duplicate;
  110. /* Treat reserved fields as constant (zero) instead of ignoring
  111. their value when determining decode tables */
  112. int zero_reserved;
  113. /* Convert any padded switch rules into goto_switch */
  114. int switch_as_goto;
  115. /* Force all tables to be generated with this lookup mechanism */
  116. char *overriding_gen;
  117. };
  118. typedef struct _igen_warn_options igen_warn_options;
  119. struct _igen_warn_options
  120. {
  121. /* Issue warning about discarded instructions */
  122. int discard;
  123. /* Issue warning about invalid instruction widths */
  124. int width;
  125. /* Issue warning about unimplemented instructions */
  126. int unimplemented;
  127. };
  128. typedef struct _igen_options igen_options;
  129. struct _igen_options
  130. {
  131. /* What does the instruction look like - bit ordering, size, widths or
  132. offesets */
  133. int hi_bit_nr;
  134. int insn_bit_size;
  135. int insn_specifying_widths;
  136. /* what should global names be prefixed with? */
  137. igen_module_options module;
  138. /* See above for options and flags */
  139. igen_gen_options gen;
  140. /* See above for trace options */
  141. igen_trace_options trace;
  142. /* See above for include options */
  143. table_include *include;
  144. /* See above for decode options */
  145. igen_decode_options decode;
  146. /* Filter set to be used on the flag field of the instruction table */
  147. filter *flags_filter;
  148. /* See above for warn options */
  149. igen_warn_options warn;
  150. /* Be more picky about the input */
  151. error_func (*warning);
  152. /* Model (processor) set - like flags_filter. Used to select the
  153. specific ISA within a processor family. */
  154. filter *model_filter;
  155. /* Format name set */
  156. filter *format_name_filter;
  157. };
  158. extern igen_options options;
  159. /* default options - hopefully backward compatible */
  160. #define INIT_OPTIONS() \
  161. do { \
  162. memset (&options, 0, sizeof options); \
  163. memset (&options.warn, -1, sizeof (options.warn)); \
  164. options.hi_bit_nr = 0; \
  165. options.insn_bit_size = default_insn_bit_size; \
  166. options.insn_specifying_widths = 0; \
  167. options.module.global.prefix.u = ""; \
  168. options.module.global.prefix.l = ""; \
  169. /* the prefixes */ \
  170. options.module.engine = options.module.global; \
  171. options.module.icache = options.module.global; \
  172. options.module.idecode = options.module.global; \
  173. options.module.itable = options.module.global; \
  174. options.module.semantics = options.module.global; \
  175. options.module.support = options.module.global; \
  176. /* the suffixes */ \
  177. options.module.engine.suffix.l = "engine"; \
  178. options.module.engine.suffix.u = "ENGINE"; \
  179. options.module.icache.suffix.l = "icache"; \
  180. options.module.icache.suffix.u = "ICACHE"; \
  181. options.module.idecode.suffix.l = "idecode"; \
  182. options.module.idecode.suffix.u = "IDECODE"; \
  183. options.module.itable.suffix.l = "itable"; \
  184. options.module.itable.suffix.u = "ITABLE"; \
  185. options.module.semantics.suffix.l = "semantics"; \
  186. options.module.semantics.suffix.u = "SEMANTICS"; \
  187. options.module.support.suffix.l = "support"; \
  188. options.module.support.suffix.u = "SUPPORT"; \
  189. /* misc stuff */ \
  190. options.gen.code = generate_calls; \
  191. options.gen.icache_size = 1024; \
  192. options.warning = warning; \
  193. } while (0)