comparison gcc/genopinit.c @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children 1830386684a0
comparison
equal deleted inserted replaced
130:e108057fa461 132:d34655255c78
1 /* Generate code to initialize optabs from machine description. 1 /* Generate code to initialize optabs from machine description.
2 Copyright (C) 1993-2017 Free Software Foundation, Inc. 2 Copyright (C) 1993-2018 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it under 6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free 7 the terms of the GNU General Public License as published by the Free
100 fatal ("cannot open file %s: %s", file_name, xstrerror (errno)); 100 fatal ("cannot open file %s: %s", file_name, xstrerror (errno));
101 fprintf (f, 101 fprintf (f,
102 "/* Generated automatically by the program `genopinit'\n" 102 "/* Generated automatically by the program `genopinit'\n"
103 " from the machine description file `md'. */\n\n"); 103 " from the machine description file `md'. */\n\n");
104 return f; 104 return f;
105 }
106
107 /* Declare the maybe_code_for_* function for ONAME, and provide
108 an inline definition of the assserting code_for_* wrapper. */
109
110 static void
111 handle_overloaded_code_for (FILE *file, overloaded_name *oname)
112 {
113 fprintf (file, "\nextern insn_code maybe_code_for_%s (", oname->name);
114 for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
115 fprintf (file, "%s%s", i == 0 ? "" : ", ", oname->arg_types[i]);
116 fprintf (file, ");\n");
117
118 fprintf (file, "inline insn_code\ncode_for_%s (", oname->name);
119 for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
120 fprintf (file, "%s%s arg%d", i == 0 ? "" : ", ", oname->arg_types[i], i);
121 fprintf (file, ")\n{\n insn_code code = maybe_code_for_%s (", oname->name);
122 for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
123 fprintf (file, "%sarg%d", i == 0 ? "" : ", ", i);
124 fprintf (file,
125 ");\n"
126 " gcc_assert (code != CODE_FOR_nothing);\n"
127 " return code;\n"
128 "}\n");
129 }
130
131 /* Declare the maybe_gen_* function for ONAME, and provide
132 an inline definition of the assserting gen_* wrapper. */
133
134 static void
135 handle_overloaded_gen (FILE *file, overloaded_name *oname)
136 {
137 pattern_stats stats;
138 get_pattern_stats (&stats, XVEC (oname->first_instance->insn, 1));
139
140 fprintf (file, "\nextern rtx maybe_gen_%s (", oname->name);
141 for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
142 fprintf (file, "%s%s", i == 0 ? "" : ", ", oname->arg_types[i]);
143 for (int i = 0; i < stats.num_generator_args; ++i)
144 fprintf (file, ", rtx");
145 fprintf (file, ");\n");
146
147 fprintf (file, "inline rtx\ngen_%s (", oname->name);
148 for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
149 fprintf (file, "%s%s arg%d", i == 0 ? "" : ", ", oname->arg_types[i], i);
150 for (int i = 0; i < stats.num_generator_args; ++i)
151 fprintf (file, ", rtx x%d", i);
152 fprintf (file, ")\n{\n rtx res = maybe_gen_%s (", oname->name);
153 for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
154 fprintf (file, "%sarg%d", i == 0 ? "" : ", ", i);
155 for (int i = 0; i < stats.num_generator_args; ++i)
156 fprintf (file, ", x%d", i);
157 fprintf (file,
158 ");\n"
159 " gcc_assert (res);\n"
160 " return res;\n"
161 "}\n");
105 } 162 }
106 163
107 int 164 int
108 main (int argc, const char **argv) 165 main (int argc, const char **argv)
109 { 166 {
218 "\n" 275 "\n"
219 "static inline enum rtx_code\n" 276 "static inline enum rtx_code\n"
220 "optab_to_code (optab op)\n" 277 "optab_to_code (optab op)\n"
221 "{\n" 278 "{\n"
222 " return optab_to_code_[op];\n" 279 " return optab_to_code_[op];\n"
223 "}\n" 280 "}\n");
281
282 for (overloaded_name *oname = rtx_reader_ptr->get_overloads ();
283 oname; oname = oname->next)
284 {
285 handle_overloaded_code_for (h_file, oname);
286 handle_overloaded_gen (h_file, oname);
287 }
288
289 fprintf (h_file,
224 "#endif\n" 290 "#endif\n"
225 "\n" 291 "\n"
226 "extern const struct convert_optab_libcall_d convlib_def[NUM_CONVLIB_OPTABS];\n" 292 "extern const struct convert_optab_libcall_d convlib_def[NUM_CONVLIB_OPTABS];\n"
227 "extern const struct optab_libcall_d normlib_def[NUM_NORMLIB_OPTABS];\n" 293 "extern const struct optab_libcall_d normlib_def[NUM_NORMLIB_OPTABS];\n"
228 "\n" 294 "\n"
232 "\n" 298 "\n"
233 "/* Target-dependent globals. */\n" 299 "/* Target-dependent globals. */\n"
234 "struct target_optabs {\n" 300 "struct target_optabs {\n"
235 " /* Patterns that are used by optabs that are enabled for this target. */\n" 301 " /* Patterns that are used by optabs that are enabled for this target. */\n"
236 " bool pat_enable[NUM_OPTAB_PATTERNS];\n" 302 " bool pat_enable[NUM_OPTAB_PATTERNS];\n"
303 "\n"
304 " /* Cache if the target supports vec_gather_load for at least one vector\n"
305 " mode. */\n"
306 " bool supports_vec_gather_load;\n"
307 " bool supports_vec_gather_load_cached;\n"
308 " bool supports_vec_scatter_store;\n"
309 " bool supports_vec_scatter_store_cached;\n"
237 "};\n" 310 "};\n"
238 "extern void init_all_optabs (struct target_optabs *);\n" 311 "extern void init_all_optabs (struct target_optabs *);\n"
239 "\n" 312 "\n"
240 "extern struct target_optabs default_target_optabs;\n" 313 "extern struct target_optabs default_target_optabs;\n"
241 "extern struct target_optabs *this_fn_optabs;\n" 314 "extern struct target_optabs *this_fn_optabs;\n"
244 "#else\n" 317 "#else\n"
245 "#define this_target_optabs (&default_target_optabs)\n" 318 "#define this_target_optabs (&default_target_optabs)\n"
246 "#endif\n"); 319 "#endif\n");
247 320
248 fprintf (s_file, 321 fprintf (s_file,
322 "#define IN_TARGET_CODE 1\n"
249 "#include \"config.h\"\n" 323 "#include \"config.h\"\n"
250 "#include \"system.h\"\n" 324 "#include \"system.h\"\n"
251 "#include \"coretypes.h\"\n" 325 "#include \"coretypes.h\"\n"
252 "#include \"backend.h\"\n" 326 "#include \"backend.h\"\n"
253 "#include \"predict.h\"\n" 327 "#include \"predict.h\"\n"