This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix illegal cast to rtx (*insn_gen_fn) (rtx, ...)
- From: Stefan Kristiansson <stefan dot kristiansson at saunalahti dot fi>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 11 Jul 2013 09:50:28 +0300
- Subject: Re: [PATCH] Fix illegal cast to rtx (*insn_gen_fn) (rtx, ...)
- References: <20130710011456 dot GA25947 at chokladfabriken dot org> <mvma9luubky dot fsf at hawking dot suse dot de>
On Wed, Jul 10, 2013 at 09:18:53AM +0200, Andreas Schwab wrote:
>
> I don't think there is a need to conditionalize this on
> HAVE_DESIGNATED_UNION_INITIALIZERS. All function pointers are alike, so
> it should be good enough to cast on assignment and use the right
> alternative on call.
You mean something like this?
gcc/recog.h:
@@ -298,7 +297,21 @@
insn_output_fn function;
} output;
#endif
- const insn_gen_fn genfun;
+ union {
+ rtx (*argc0) (void);
+ rtx (*argc1) (rtx);
+ rtx (*argc2) (rtx, rtx);
+ rtx (*argc3) (rtx, rtx, rtx);
+ rtx (*argc4) (rtx, rtx, rtx, rtx);
+ rtx (*argc5) (rtx, rtx, rtx, rtx, rtx);
+ rtx (*argc6) (rtx, rtx, rtx, rtx, rtx, rtx);
+ rtx (*argc7) (rtx, rtx, rtx, rtx, rtx, rtx, rtx);
+ rtx (*argc8) (rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx);
+ rtx (*argc9) (rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx);
+ rtx (*argc10) (rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx);
+ rtx (*argc11) (rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx, rtx);
+ } genfun;
+
const struct insn_operand_data *const operand;
const char n_generator_args;
gcc/genoutput.c:
@@ -404,9 +404,9 @@
}
if (d->name && d->name[0] != '*')
- printf (" (insn_gen_fn) gen_%s,\n", d->name);
+ printf (" { (rtx (*) (void)) gen_%s },\n", d->name);
else
- printf (" 0,\n");
+ printf (" { 0 },\n");
printf (" &operand_data[%d],\n", d->operand_number);
printf (" %d,\n", d->n_generator_args);
Fair enough, that makes the printing routine a bit more clean and
removes some code duplication in the declaration.
Stefan