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/>.
25 #include "ld-decode.h"
31 #include "gen-semantics.h"
32 #include "gen-support.h"
35 print_support_function_name(lf
*file
,
36 table_entry
*function
,
37 int is_function_definition
)
39 if (it_is("internal", function
->fields
[insn_flags
])) {
40 lf_print_function_type(file
, SEMANTIC_FUNCTION_TYPE
, "PSIM_INLINE_SUPPORT",
41 (is_function_definition
? "\n" : " "));
42 print_function_name(file
,
43 function
->fields
[function_name
],
45 function_name_prefix_semantics
);
46 lf_printf(file
, "\n(%s)", SEMANTIC_FUNCTION_FORMAL
);
47 if (!is_function_definition
)
49 lf_printf(file
, "\n");
52 lf_print_function_type(file
,
53 function
->fields
[function_type
],
54 "PSIM_INLINE_SUPPORT",
55 (is_function_definition
? "\n" : " "));
56 lf_printf(file
, "%s\n(%s)%s",
57 function
->fields
[function_name
],
58 function
->fields
[function_param
],
59 (is_function_definition
? "\n" : ";\n"));
65 support_h_function(insn_table
*entry
,
68 table_entry
*function
)
70 ASSERT(function
->fields
[function_type
] != NULL
);
71 ASSERT(function
->fields
[function_param
] != NULL
);
72 print_support_function_name(file
,
75 lf_printf(file
, "\n");
80 gen_support_h(insn_table
*table
,
83 /* output a declaration for all functions */
84 insn_table_traverse_function(table
,
87 lf_printf(file
, "\n");
88 lf_printf(file
, "#if (SUPPORT_INLINE & INCLUDE_MODULE)\n");
89 lf_printf(file
, "# include \"support.c\"\n");
90 lf_printf(file
, "#endif\n");
94 support_c_function(insn_table
*table
,
97 table_entry
*function
)
99 ASSERT(function
->fields
[function_type
] != NULL
);
100 print_support_function_name(file
,
102 1/*!is_definition*/);
103 table_entry_print_cpp_line_nr(file
, function
);
104 lf_printf(file
, "{\n");
106 lf_print__c_code(file
, function
->annex
);
107 if (it_is("internal", function
->fields
[insn_flags
])) {
108 lf_printf(file
, "error(\"Internal function must longjump\\n\");\n");
109 lf_printf(file
, "return 0;\n");
112 lf_printf(file
, "}\n");
113 lf_print__internal_reference(file
);
114 lf_printf(file
, "\n");
119 gen_support_c(insn_table
*table
,
122 lf_printf(file
, "#include \"cpu.h\"\n");
123 lf_printf(file
, "#include \"idecode.h\"\n");
124 lf_printf(file
, "#ifdef HAVE_COMMON_FPU\n");
125 lf_printf(file
, "#include \"sim-inline.h\"\n");
126 lf_printf(file
, "#include \"sim-fpu.h\"\n");
127 lf_printf(file
, "#endif\n");
128 lf_printf(file
, "#include \"support.h\"\n");
129 lf_printf(file
, "\n");
131 /* output a definition (c-code) for all functions */
132 insn_table_traverse_function(table
,