]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - sim/igen/gen.h
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / sim / igen / gen.h
CommitLineData
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
7 the Free Software Foundation; either version 2 of the License, or
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
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 */
20
21
22typedef struct _opcode_field opcode_field;
23struct _opcode_field {
24 int word_nr;
25 int first;
26 int last;
27 int is_boolean;
28 int nr_opcodes;
29 unsigned boolean_constant;
30 opcode_field *parent;
31};
32
33typedef struct _opcode_bits opcode_bits;
34struct _opcode_bits {
35 int value;
36 int first;
37 int last;
38 insn_field_entry *field;
39 opcode_field *opcode;
40 opcode_bits *next;
41};
42
43typedef struct _insn_opcodes insn_opcodes;
44struct _insn_opcodes {
45 opcode_field *opcode;
46 insn_opcodes *next;
47};
48
49typedef struct _insn_list insn_list;
50struct _insn_list {
51 /* the instruction */
52 insn_entry *insn;
53 /* list of non constant bits that have been made constant */
54 opcode_bits *expanded_bits;
55 /* list of the various opcode field paths used to reach this
56 instruction */
57 insn_opcodes *opcodes;
58 /* number of prefetched words for this instruction */
59 int nr_prefetched_words;
60 /* The semantic function list_entry corresponding to this insn */
61 insn_list *semantic;
62 /* linked list */
63 insn_list *next;
64};
65
66/* forward */
67typedef struct _gen_list gen_list;
68
69typedef struct _gen_entry gen_entry;
70struct _gen_entry {
71
72 /* as an entry in a table */
73 int word_nr;
74 int opcode_nr;
75 gen_entry *sibling;
76 opcode_bits *expanded_bits;
77 gen_entry *parent; /* parent has the opcode* data */
78
79 /* as a table containing entries */
80 decode_table *opcode_rule;
81 opcode_field *opcode;
82 int nr_prefetched_words;
83 int nr_entries;
84 gen_entry *entries;
85
86 /* as both an entry and a table */
87 int nr_insns;
88 insn_list *insns;
89
90 /* if siblings are being combined */
91 gen_entry *combined_next;
92 gen_entry *combined_parent;
93
94 /* our top-of-tree */
95 gen_list *top;
96};
97
98
99struct _gen_list {
100 model_entry *model;
101 insn_table *isa;
102 gen_entry *table;
103 gen_list *next;
104};
105
106
107typedef struct _gen_table gen_table;
108struct _gen_table {
109 /* list of all the instructions */
110 insn_table *isa;
111 /* list of all the semantic functions */
112 decode_table *rules;
113 /* list of all the generated instruction tables */
114 gen_list *tables;
115 /* list of all the semantic functions */
116 int nr_semantics;
117 insn_list *semantics;
118};
119
120
121extern gen_table *make_gen_tables
122(insn_table *isa,
123 decode_table *rules);
124
125
126extern void gen_tables_expand_insns
127(gen_table *gen);
128
129extern void gen_tables_expand_semantics
130(gen_table *gen);
131
132extern int gen_entry_depth
133(gen_entry *table);
134
135
136
137/* Traverse the created data structure */
138
139typedef void gen_entry_handler
140(lf *file,
141 gen_entry *entry,
142 int depth,
143 void *data);
144
145extern void gen_entry_traverse_tree
146(lf *file,
147 gen_entry *table,
148 int depth,
149 gen_entry_handler *start,
150 gen_entry_handler *leaf,
151 gen_entry_handler *end,
152 void *data);
153
154
155
156/* Misc functions - actually in igen.c */
157
158
159/* Cache functions: */
160
161extern int print_icache_function_formal
162(lf *file, int nr_prefetched_words);
163
164extern int print_icache_function_actual
165(lf *file, int nr_prefetched_words);
166
167extern int print_icache_function_type
168(lf *file);
169
170extern int print_semantic_function_formal
171(lf *file, int nr_prefetched_words);
172
173extern int print_semantic_function_actual
174(lf *file, int nr_prefetched_words);
175
176extern int print_semantic_function_type
177(lf *file);
178
179extern int print_idecode_function_formal
180(lf *file, int nr_prefetched_words);
181
182extern int print_idecode_function_actual
183(lf *file, int nr_prefetched_words);
184
185typedef enum {
186 function_name_prefix_semantics,
187 function_name_prefix_idecode,
188 function_name_prefix_itable,
189 function_name_prefix_icache,
190 function_name_prefix_engine,
191 function_name_prefix_none
192} lf_function_name_prefixes;
193
194typedef enum {
195 is_function_declaration = 0,
196 is_function_definition = 1,
197 is_function_variable,
198} function_decl_type;
199
200extern int print_function_name
201(lf *file,
202 const char *basename,
203 const char *format_name,
204 const char *model_name,
205 opcode_bits *expanded_bits,
206 lf_function_name_prefixes prefix);
207
208extern void print_my_defines
209(lf *file,
210 const char *basename,
211 const char *format_name,
212 opcode_bits *expanded_bits);
213
214extern void print_itrace
215(lf *file,
216 insn_entry *insn,
217 int idecode);
218
219extern void print_sim_engine_abort
220(lf *file,
221 const char *message);
222
223
224extern void print_include (lf *file, igen_module module);
225extern void print_include_inline (lf *file, igen_module module);
226extern void print_includes (lf *file);
227