Update copyright year in gdbarch.sh doc/gdb.texinfo and doc/refcard.tex
[binutils-gdb.git] / sim / ppc / gen-itable.c
blob7f3139ed971f73c1a7cb22e3ca743fb9d536d36a
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 3 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, see <http://www.gnu.org/licenses/>.
22 #include "misc.h"
23 #include "lf.h"
24 #include "table.h"
26 #include "filter.h"
28 #include "ld-cache.h"
29 #include "ld-decode.h"
30 #include "ld-insn.h"
32 #include "igen.h"
33 #include "gen-itable.h"
35 #ifndef NULL
36 #define NULL 0
37 #endif
41 static void
42 itable_h_insn(insn_table *entry,
43 lf *file,
44 void *data,
45 insn *instruction,
46 int depth)
48 lf_printf(file, " ");
49 print_function_name(file,
50 instruction->file_entry->fields[insn_name],
51 NULL,
52 function_name_prefix_itable);
53 lf_printf(file, ",\n");
57 extern void
58 gen_itable_h(insn_table *table, lf *file)
60 /* output an enumerated type for each instruction */
61 lf_printf(file, "typedef enum {\n");
62 insn_table_traverse_insn(table,
63 file, NULL,
64 itable_h_insn);
65 lf_printf(file, " nr_itable_entries,\n");
66 lf_printf(file, "} itable_index;\n");
67 lf_printf(file, "\n");
69 /* output the table that contains the actual instruction info */
70 lf_printf(file, "typedef struct _itable_instruction_info {\n");
71 lf_printf(file, " itable_index nr;\n");
72 lf_printf(file, " char *format;\n");
73 lf_printf(file, " char *form;\n");
74 lf_printf(file, " char *flags;\n");
75 lf_printf(file, " char *mnemonic;\n");
76 lf_printf(file, " char *name;\n");
77 lf_printf(file, " char *file;\n");
78 lf_printf(file, " int line_nr;\n");
79 lf_printf(file, "} itable_info;\n");
80 lf_printf(file, "\n");
81 lf_printf(file, "extern itable_info itable[nr_itable_entries];\n");
84 /****************************************************************/
86 static void
87 itable_c_insn(insn_table *entry,
88 lf *file,
89 void *data,
90 insn *instruction,
91 int depth)
93 char **fields = instruction->file_entry->fields;
94 lf_printf(file, " { ");
95 print_function_name(file,
96 instruction->file_entry->fields[insn_name],
97 NULL,
98 function_name_prefix_itable);
99 lf_printf(file, ",\n");
100 lf_printf(file, " \"%s\",\n", fields[insn_format]);
101 lf_printf(file, " \"%s\",\n", fields[insn_form]);
102 lf_printf(file, " \"%s\",\n", fields[insn_flags]);
103 lf_printf(file, " \"%s\",\n", fields[insn_mnemonic]);
104 lf_printf(file, " \"%s\",\n", fields[insn_name]);
105 lf_printf(file, " \"%s\",\n", filter_filename (instruction->file_entry->file_name));
106 lf_printf(file, " %d,\n", instruction->file_entry->line_nr);
107 lf_printf(file, " },\n");
111 extern void
112 gen_itable_c(insn_table *table, lf *file)
114 /* output the table that contains the actual instruction info */
115 lf_printf(file, "#include \"itable.h\"\n");
116 lf_printf(file, "\n");
117 lf_printf(file, "itable_info itable[nr_itable_entries] = {\n");
118 insn_table_traverse_insn(table,
119 file, NULL,
120 itable_c_insn);
121 lf_printf(file, "};\n");