]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1995, Andrew Cagney <[email protected]> | |
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 | |
3fd725ef | 7 | the Free Software Foundation; either version 3 of the License, or |
c906108c SS |
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 | |
51b318de | 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
17 | |
18 | */ | |
19 | ||
20 | ||
21 | ||
22 | #include "misc.h" | |
23 | #include "lf.h" | |
24 | #include "table.h" | |
25 | ||
26 | #include "filter.h" | |
27 | ||
d81bb16a | 28 | #include "ld-cache.h" |
c906108c SS |
29 | #include "ld-decode.h" |
30 | #include "ld-insn.h" | |
31 | ||
32 | #include "igen.h" | |
33 | #include "gen-itable.h" | |
34 | ||
c906108c SS |
35 | |
36 | static void | |
37 | itable_h_insn(insn_table *entry, | |
38 | lf *file, | |
39 | void *data, | |
40 | insn *instruction, | |
41 | int depth) | |
42 | { | |
43 | lf_printf(file, " "); | |
44 | print_function_name(file, | |
45 | instruction->file_entry->fields[insn_name], | |
46 | NULL, | |
47 | function_name_prefix_itable); | |
48 | lf_printf(file, ",\n"); | |
49 | } | |
50 | ||
51 | ||
52 | extern void | |
53 | gen_itable_h(insn_table *table, lf *file) | |
54 | { | |
55 | /* output an enumerated type for each instruction */ | |
56 | lf_printf(file, "typedef enum {\n"); | |
57 | insn_table_traverse_insn(table, | |
58 | file, NULL, | |
59 | itable_h_insn); | |
60 | lf_printf(file, " nr_itable_entries,\n"); | |
61 | lf_printf(file, "} itable_index;\n"); | |
62 | lf_printf(file, "\n"); | |
63 | ||
64 | /* output the table that contains the actual instruction info */ | |
65 | lf_printf(file, "typedef struct _itable_instruction_info {\n"); | |
66 | lf_printf(file, " itable_index nr;\n"); | |
fc3579da MF |
67 | lf_printf(file, " const char *format;\n"); |
68 | lf_printf(file, " const char *form;\n"); | |
69 | lf_printf(file, " const char *flags;\n"); | |
70 | lf_printf(file, " const char *mnemonic;\n"); | |
71 | lf_printf(file, " const char *name;\n"); | |
72 | lf_printf(file, " const char *file;\n"); | |
c906108c SS |
73 | lf_printf(file, " int line_nr;\n"); |
74 | lf_printf(file, "} itable_info;\n"); | |
75 | lf_printf(file, "\n"); | |
76 | lf_printf(file, "extern itable_info itable[nr_itable_entries];\n"); | |
77 | } | |
78 | ||
79 | /****************************************************************/ | |
80 | ||
81 | static void | |
82 | itable_c_insn(insn_table *entry, | |
83 | lf *file, | |
84 | void *data, | |
85 | insn *instruction, | |
86 | int depth) | |
87 | { | |
88 | char **fields = instruction->file_entry->fields; | |
89 | lf_printf(file, " { "); | |
90 | print_function_name(file, | |
91 | instruction->file_entry->fields[insn_name], | |
92 | NULL, | |
93 | function_name_prefix_itable); | |
94 | lf_printf(file, ",\n"); | |
95 | lf_printf(file, " \"%s\",\n", fields[insn_format]); | |
96 | lf_printf(file, " \"%s\",\n", fields[insn_form]); | |
97 | lf_printf(file, " \"%s\",\n", fields[insn_flags]); | |
98 | lf_printf(file, " \"%s\",\n", fields[insn_mnemonic]); | |
99 | lf_printf(file, " \"%s\",\n", fields[insn_name]); | |
100 | lf_printf(file, " \"%s\",\n", filter_filename (instruction->file_entry->file_name)); | |
101 | lf_printf(file, " %d,\n", instruction->file_entry->line_nr); | |
102 | lf_printf(file, " },\n"); | |
103 | } | |
104 | ||
105 | ||
106 | extern void | |
107 | gen_itable_c(insn_table *table, lf *file) | |
108 | { | |
109 | /* output the table that contains the actual instruction info */ | |
110 | lf_printf(file, "#include \"itable.h\"\n"); | |
111 | lf_printf(file, "\n"); | |
112 | lf_printf(file, "itable_info itable[nr_itable_entries] = {\n"); | |
113 | insn_table_traverse_insn(table, | |
114 | file, NULL, | |
115 | itable_c_insn); | |
116 | lf_printf(file, "};\n"); | |
117 | } |