1 /* This file is part of the program psim.
3 Copyright (C) 1994-1995, Andrew Cagney <cagney@highland.com.au>
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.
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.
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.
30 #include "ld-decode.h"
34 #include "gen-itable.h"
43 itable_h_insn (lf *file,
45 insn_entry *instruction,
48 lf_print__line_ref (file, instruction->line);
49 lf_printf (file, " ");
50 print_function_name (file,
52 instruction->format_name,
55 function_name_prefix_itable);
56 lf_printf (file, ",\n");
60 /* print the list of all the different options */
63 itable_print_enum (lf *file,
68 lf_printf (file, "typedef enum {\n");
70 for (elem = filter_next (set, "");
72 elem = filter_next (set, elem))
74 lf_printf (file, "%sitable_%s_%s,\n",
75 options.prefix.itable.name, name, elem);
76 if (strlen (options.prefix.itable.name) > 0)
78 lf_indent_suppress (file);
79 lf_printf (file, "#define itable_%s_%s %sitable_%s_%s\n",
80 name, elem, options.prefix.itable.name, name, elem);
83 lf_printf (file, "nr_%sitable_%ss,", options.prefix.itable.name, name);
86 lf_printf (file, "\n} %sitable_%ss;\n", options.prefix.itable.name, name);
87 if (strlen (options.prefix.itable.name) > 0)
89 lf_indent_suppress (file);
90 lf_printf (file, "#define itable_%ss %sitable_%ss\n",
91 name, options.prefix.itable.name, name);
92 lf_indent_suppress (file);
93 lf_printf (file, "#define nr_itable_%ss nr_%sitable_%ss\n",
94 name, options.prefix.itable.name, name);
96 lf_printf (file, "\n");
100 gen_itable_h (lf *file,
104 /* output an enumerated type for each instruction */
105 lf_printf (file, "typedef enum {\n");
106 insn_table_traverse_insn (file, isa, itable_h_insn, NULL);
107 lf_printf (file, " nr_%sitable_entries,\n", options.prefix.itable.name);
108 lf_printf (file, "} %sitable_index;\n", options.prefix.itable.name);
109 lf_printf (file, "\n");
111 /* output an enumeration type for each flag */
112 itable_print_enum (file, isa->flags, "flag");
114 /* output an enumeration of all the possible options */
115 itable_print_enum (file, isa->options, "option");
117 /* output an enumeration of all the processor models */
118 itable_print_enum (file, isa->model->processors, "processor");
120 /* output the table that contains the actual instruction info */
121 lf_printf (file, "typedef struct _%sitable_instruction_info {\n",
122 options.prefix.itable.name);
123 lf_printf (file, " %sitable_index nr;\n", options.prefix.itable.name);
124 lf_printf (file, " char *format;\n");
125 lf_printf (file, " char *form;\n");
126 lf_printf (file, " char *flags;\n");
127 lf_printf (file, " char flag[nr_%sitable_flags];\n",
128 options.prefix.itable.name);
129 lf_printf (file, " char *options;\n");
130 lf_printf (file, " char option[nr_%sitable_options];\n",
131 options.prefix.itable.name);
132 lf_printf (file, " char *processors;\n");
133 lf_printf (file, " char processor[nr_%sitable_processors];\n",
134 options.prefix.itable.name);
135 lf_printf (file, " char *name;\n");
136 lf_printf (file, " char *file;\n");
137 lf_printf (file, " int line_nr;\n");
138 lf_printf (file, "} %sitable_info;\n", options.prefix.itable.name);
139 lf_printf (file, "\n");
140 lf_printf (file, "extern %sitable_info %sitable[nr_%sitable_entries];\n",
141 options.prefix.itable.name, options.prefix.itable.name,
142 options.prefix.itable.name);
143 if (strlen (options.prefix.itable.name) > 0)
145 lf_indent_suppress (file);
146 lf_printf (file, "#define itable %sitable\n",
147 options.prefix.itable.name);
152 /****************************************************************/
155 itable_print_set (lf *file,
160 lf_printf (file, "\"");
161 elem = filter_next (members, "");
166 lf_printf (file, "%s", elem);
167 elem = filter_next (members, elem);
170 lf_printf (file, ",");
173 lf_printf (file, "\",\n");
175 lf_printf(file, "{");
176 for (elem = filter_next (set, "");
178 elem = filter_next (set, elem))
180 if (filter_is_member (members, elem))
182 lf_printf (file, " 1,");
186 lf_printf (file, " 0,");
190 lf_printf(file, " },\n");
195 itable_c_insn (lf *file,
197 insn_entry *instruction,
200 lf_printf (file, "{ ");
201 lf_indent (file, +2);
202 print_function_name (file,
204 instruction->format_name,
207 function_name_prefix_itable);
208 lf_printf (file, ",\n");
209 lf_printf (file, "\"");
210 print_insn_words (file, instruction);
211 lf_printf (file, "\",\n");
212 lf_printf (file, "\"%s\",\n", instruction->format_name);
214 itable_print_set (file, isa->flags, instruction->flags);
215 itable_print_set (file, isa->options, instruction->options);
216 itable_print_set (file, isa->model->processors, instruction->processors);
218 lf_printf(file, "\"%s\",\n", instruction->name);
219 lf_printf(file, "\"%s\",\n",
220 filter_filename (instruction->line->file_name));
221 lf_printf(file, "%d,\n", instruction->line->line_nr);
222 lf_printf(file, "},\n");
223 lf_indent (file, -2);
228 gen_itable_c (lf *file,
232 lf_printf(file, "#include \"%sitable.h\"\n", options.prefix.itable.name);
233 lf_printf(file, "\n");
235 /* FIXME - output model data??? */
236 /* FIXME - output assembler data??? */
238 /* output the table that contains the actual instruction info */
239 lf_printf(file, "%sitable_info %sitable[nr_%sitable_entries] = {\n",
240 options.prefix.itable.name,
241 options.prefix.itable.name,
242 options.prefix.itable.name);
243 insn_table_traverse_insn (file, isa, itable_c_insn, NULL);
245 lf_printf(file, "};\n");