ld: Move the .note.build-id section to near the start of the memory map.
[binutils-gdb.git] / sim / ppc / gen-support.c
blob5a192fdd0002da05b330c54fdfea13554e41d62e
1 /* This file is part of the program psim.
3 Copyright 1994, 1995, 2003 Andrew Cagney
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/>.
20 #include "misc.h"
21 #include "lf.h"
22 #include "lf-ppc.h"
23 #include "table.h"
24 #include "filter.h"
25 #include "filter-ppc.h"
27 #include "ld-decode.h"
28 #include "ld-cache.h"
29 #include "ld-insn.h"
31 #include "igen.h"
33 #include "gen-semantics.h"
34 #include "gen-support.h"
36 static void
37 print_support_function_name(lf *file,
38 table_entry *function,
39 int is_function_definition)
41 if (it_is("internal", function->fields[insn_flags])) {
42 lf_print__function_type(file, SEMANTIC_FUNCTION_TYPE, "PSIM_INLINE_SUPPORT",
43 (is_function_definition ? "\n" : " "));
44 print_function_name(file,
45 function->fields[function_name],
46 NULL,
47 function_name_prefix_semantics);
48 lf_printf(file, "\n(%s)", SEMANTIC_FUNCTION_FORMAL);
49 if (!is_function_definition)
50 lf_printf(file, ";");
51 lf_printf(file, "\n");
53 else {
54 lf_print__function_type(file,
55 function->fields[function_type],
56 "PSIM_INLINE_SUPPORT",
57 (is_function_definition ? "\n" : " "));
58 lf_printf(file, "%s\n(%s)%s",
59 function->fields[function_name],
60 function->fields[function_param],
61 (is_function_definition ? "\n" : ";\n"));
66 static void
67 support_h_function(insn_table *entry,
68 lf *file,
69 void *data,
70 table_entry *function)
72 ASSERT(function->fields[function_type] != NULL);
73 ASSERT(function->fields[function_param] != NULL);
74 print_support_function_name(file,
75 function,
76 0/*!is_definition*/);
77 lf_printf(file, "\n");
81 extern void
82 gen_support_h(insn_table *table,
83 lf *file)
85 /* output a declaration for all functions */
86 insn_table_traverse_function(table,
87 file, NULL,
88 support_h_function);
89 lf_printf(file, "\n");
90 lf_printf(file, "#if (SUPPORT_INLINE & INCLUDE_MODULE)\n");
91 lf_printf(file, "# include \"support.c\"\n");
92 lf_printf(file, "#endif\n");
95 static void
96 support_c_function(insn_table *table,
97 lf *file,
98 void *data,
99 table_entry *function)
101 ASSERT(function->fields[function_type] != NULL);
102 print_support_function_name(file,
103 function,
104 1/*!is_definition*/);
105 table_entry_print_cpp_line_nr(file, function);
106 lf_printf(file, "{\n");
107 lf_indent(file, +2);
108 lf_print__c_code(file, function->annex);
109 if (it_is("internal", function->fields[insn_flags])) {
110 lf_printf(file, "error(\"Internal function must longjump\\n\");\n");
111 lf_printf(file, "return 0;\n");
113 lf_indent(file, -2);
114 lf_printf(file, "}\n");
115 lf_print__internal_ref(file);
116 lf_printf(file, "\n");
120 void
121 gen_support_c(insn_table *table,
122 lf *file)
124 lf_printf(file, "#include \"cpu.h\"\n");
125 lf_printf(file, "#include \"idecode.h\"\n");
126 lf_printf(file, "#ifdef HAVE_COMMON_FPU\n");
127 lf_printf(file, "#include \"sim-inline.h\"\n");
128 lf_printf(file, "#include \"sim-fpu.h\"\n");
129 lf_printf(file, "#endif\n");
130 lf_printf(file, "#include \"support.h\"\n");
131 lf_printf(file, "\n");
133 /* output a definition (c-code) for all functions */
134 insn_table_traverse_function(table,
135 file, NULL,
136 support_c_function);