comparison gcc/genopinit.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Generate code to initialize optabs from machine description. 1 /* Generate code to initialize optabs from machine description.
2 Copyright (C) 1993-2018 Free Software Foundation, Inc. 2 Copyright (C) 1993-2020 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
132 an inline definition of the assserting gen_* wrapper. */ 132 an inline definition of the assserting gen_* wrapper. */
133 133
134 static void 134 static void
135 handle_overloaded_gen (FILE *file, overloaded_name *oname) 135 handle_overloaded_gen (FILE *file, overloaded_name *oname)
136 { 136 {
137 pattern_stats stats; 137 unsigned HOST_WIDE_INT seen = 0;
138 get_pattern_stats (&stats, XVEC (oname->first_instance->insn, 1)); 138 for (overloaded_instance *instance = oname->first_instance->next;
139 139 instance; instance = instance->next)
140 fprintf (file, "\nextern rtx maybe_gen_%s (", oname->name); 140 {
141 for (unsigned int i = 0; i < oname->arg_types.length (); ++i) 141 pattern_stats stats;
142 fprintf (file, "%s%s", i == 0 ? "" : ", ", oname->arg_types[i]); 142 get_pattern_stats (&stats, XVEC (instance->insn, 1));
143 for (int i = 0; i < stats.num_generator_args; ++i) 143 unsigned HOST_WIDE_INT mask
144 fprintf (file, ", rtx"); 144 = HOST_WIDE_INT_1U << stats.num_generator_args;
145 fprintf (file, ");\n"); 145 if (seen & mask)
146 146 continue;
147 fprintf (file, "inline rtx\ngen_%s (", oname->name); 147
148 for (unsigned int i = 0; i < oname->arg_types.length (); ++i) 148 seen |= mask;
149 fprintf (file, "%s%s arg%d", i == 0 ? "" : ", ", oname->arg_types[i], i); 149
150 for (int i = 0; i < stats.num_generator_args; ++i) 150 fprintf (file, "\nextern rtx maybe_gen_%s (", oname->name);
151 fprintf (file, ", rtx x%d", i); 151 for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
152 fprintf (file, ")\n{\n rtx res = maybe_gen_%s (", oname->name); 152 fprintf (file, "%s%s", i == 0 ? "" : ", ", oname->arg_types[i]);
153 for (unsigned int i = 0; i < oname->arg_types.length (); ++i) 153 for (int i = 0; i < stats.num_generator_args; ++i)
154 fprintf (file, "%sarg%d", i == 0 ? "" : ", ", i); 154 fprintf (file, ", rtx");
155 for (int i = 0; i < stats.num_generator_args; ++i) 155 fprintf (file, ");\n");
156 fprintf (file, ", x%d", i); 156
157 fprintf (file, 157 fprintf (file, "inline rtx\ngen_%s (", oname->name);
158 ");\n" 158 for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
159 " gcc_assert (res);\n" 159 fprintf (file, "%s%s arg%d", i == 0 ? "" : ", ",
160 " return res;\n" 160 oname->arg_types[i], i);
161 "}\n"); 161 for (int i = 0; i < stats.num_generator_args; ++i)
162 fprintf (file, ", rtx x%d", i);
163 fprintf (file, ")\n{\n rtx res = maybe_gen_%s (", oname->name);
164 for (unsigned int i = 0; i < oname->arg_types.length (); ++i)
165 fprintf (file, "%sarg%d", i == 0 ? "" : ", ", i);
166 for (int i = 0; i < stats.num_generator_args; ++i)
167 fprintf (file, ", x%d", i);
168 fprintf (file,
169 ");\n"
170 " gcc_assert (res);\n"
171 " return res;\n"
172 "}\n");
173 }
162 } 174 }
163 175
164 int 176 int
165 main (int argc, const char **argv) 177 main (int argc, const char **argv)
166 { 178 {