gen.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. typedef struct _opcode_field opcode_field;
  16. struct _opcode_field
  17. {
  18. int word_nr;
  19. int first;
  20. int last;
  21. int is_boolean;
  22. int nr_opcodes;
  23. unsigned boolean_constant;
  24. opcode_field *parent;
  25. };
  26. typedef struct _opcode_bits opcode_bits;
  27. struct _opcode_bits
  28. {
  29. int value;
  30. int first;
  31. int last;
  32. insn_field_entry *field;
  33. opcode_field *opcode;
  34. opcode_bits *next;
  35. };
  36. typedef struct _insn_opcodes insn_opcodes;
  37. struct _insn_opcodes
  38. {
  39. opcode_field *opcode;
  40. insn_opcodes *next;
  41. };
  42. typedef struct _insn_list insn_list;
  43. struct _insn_list
  44. {
  45. /* the instruction */
  46. insn_entry *insn;
  47. /* list of non constant bits that have been made constant */
  48. opcode_bits *expanded_bits;
  49. /* list of the various opcode field paths used to reach this
  50. instruction */
  51. insn_opcodes *opcodes;
  52. /* number of prefetched words for this instruction */
  53. int nr_prefetched_words;
  54. /* The semantic function list_entry corresponding to this insn */
  55. insn_list *semantic;
  56. /* linked list */
  57. insn_list *next;
  58. };
  59. /* forward */
  60. typedef struct _gen_list gen_list;
  61. typedef struct _gen_entry gen_entry;
  62. struct _gen_entry
  63. {
  64. /* as an entry in a table */
  65. int word_nr;
  66. int opcode_nr;
  67. gen_entry *sibling;
  68. opcode_bits *expanded_bits;
  69. gen_entry *parent; /* parent has the opcode* data */
  70. /* as a table containing entries */
  71. decode_table *opcode_rule;
  72. opcode_field *opcode;
  73. int nr_prefetched_words;
  74. int nr_entries;
  75. gen_entry *entries;
  76. /* as both an entry and a table */
  77. int nr_insns;
  78. insn_list *insns;
  79. /* if siblings are being combined */
  80. gen_entry *combined_next;
  81. gen_entry *combined_parent;
  82. /* our top-of-tree */
  83. gen_list *top;
  84. };
  85. struct _gen_list
  86. {
  87. model_entry *model;
  88. insn_table *isa;
  89. gen_entry *table;
  90. gen_list *next;
  91. };
  92. typedef struct _gen_table gen_table;
  93. struct _gen_table
  94. {
  95. /* list of all the instructions */
  96. insn_table *isa;
  97. /* list of all the semantic functions */
  98. decode_table *rules;
  99. /* list of all the generated instruction tables */
  100. gen_list *tables;
  101. /* list of all the semantic functions */
  102. int nr_semantics;
  103. insn_list *semantics;
  104. };
  105. extern gen_table *make_gen_tables (insn_table *isa, decode_table *rules);
  106. extern void gen_tables_expand_insns (gen_table *gen);
  107. extern void gen_tables_expand_semantics (gen_table *gen);
  108. extern int gen_entry_depth (gen_entry *table);
  109. /* Traverse the created data structure */
  110. typedef void gen_entry_handler
  111. (lf *file, gen_entry *entry, int depth, void *data);
  112. extern void gen_entry_traverse_tree
  113. (lf *file,
  114. gen_entry *table,
  115. int depth,
  116. gen_entry_handler * start,
  117. gen_entry_handler * leaf, gen_entry_handler * end, void *data);
  118. /* Misc functions - actually in igen.c */
  119. /* Cache functions: */
  120. extern int print_icache_function_formal (lf *file, int nr_prefetched_words);
  121. extern int print_icache_function_actual (lf *file, int nr_prefetched_words);
  122. extern int print_icache_function_type (lf *file);
  123. extern int print_semantic_function_formal (lf *file, int nr_prefetched_words);
  124. extern int print_semantic_function_actual (lf *file, int nr_prefetched_words);
  125. extern int print_semantic_function_type (lf *file);
  126. extern int print_idecode_function_formal (lf *file, int nr_prefetched_words);
  127. extern int print_idecode_function_actual (lf *file, int nr_prefetched_words);
  128. typedef enum
  129. {
  130. function_name_prefix_semantics,
  131. function_name_prefix_idecode,
  132. function_name_prefix_itable,
  133. function_name_prefix_icache,
  134. function_name_prefix_engine,
  135. function_name_prefix_none
  136. }
  137. lf_function_name_prefixes;
  138. typedef enum
  139. {
  140. is_function_declaration = 0,
  141. is_function_definition = 1,
  142. is_function_variable,
  143. }
  144. function_decl_type;
  145. extern int print_function_name
  146. (lf *file,
  147. const char *basename,
  148. const char *format_name,
  149. const char *model_name,
  150. opcode_bits *expanded_bits, lf_function_name_prefixes prefix);
  151. extern void print_my_defines
  152. (lf *file,
  153. const char *basename, const char *format_name, opcode_bits *expanded_bits);
  154. extern void print_itrace (lf *file, insn_entry * insn, int idecode);
  155. extern void print_sim_engine_abort (lf *file, const char *message);
  156. extern void print_include (lf *file, igen_module module);
  157. extern void print_include_inline (lf *file, igen_module module);
  158. extern void print_includes (lf *file);