This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: Fix optab reinitialisation when $(CC) is GCC 4.0 or above
- From: Richard Sandiford <rsandifo at nildram dot co dot uk>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 05 Dec 2007 08:08:54 +0000
- Subject: Re: RFA: Fix optab reinitialisation when $(CC) is GCC 4.0 or above
- References: <87wss5xsx9.fsf@firetop.home> <20071126095424.GD16835@devserv.devel.redhat.com>
Jakub Jelinek <jakub@redhat.com> writes:
> Perhaps it would be better to remove new_optab altogether and insn_codes
> setup code from init_convert_optab and instead add a new function,
>
> static void
> init_insn_codes (void)
> {
> int i, j, op;
>
> for (op = 0; op < OTI_MAX; op++)
> for (i = 0; i < NUM_MACHINE_MODES; i++)
> optab_handler (&optab_table[op], i)->insn_code = CODE_FOR_nothing;
> for (op = 0; op < COI_MAX; op++)
> for (i = 0; i < NUM_MACHINE_MODES; i++)
> for (j = 0; j < NUM_MACHINE_MODES; j++)
> convert_optab_handler (&convert_optab_table[op], i, j)->insn_code
> = CODE_FOR_nothing;
> }
>
> and call this either when not compiled with GCC 4.0 and above, or
> when initializing for the second and later time.
OK, no-one spoke out in favour of the original patch, and looking back,
my comments were just foolish, sorry. So here's a patch to do what you
suggest. Bootstrapped & regression-tested on x86_64-linux-gnu ({,-m32}).
Also regression-tested on mipsisa64-elfoabi. The bootstrap compiler was
GCC 3.4, so it can still build optabs.c. OK to install?
Richard
gcc/
200x-xx-xx Jakub Jelinek <jakub@redhat.com>
Richard Sandiford <rsandifo@nildram.co.uk>
* optabs.c (clear_insn_codes): New function.
(new_optab): Delete.
(init_optab, init_optabv): Don't call new_optab.
(init_convert_optab): Don't clear the insn codes.
(init_optabs): Call clear_insn_codes.
Index: gcc/optabs.c
===================================================================
--- gcc/optabs.c (revision 130598)
+++ gcc/optabs.c (working copy)
@@ -59,7 +59,7 @@ Software Foundation; either version 3, o
= { [0 ... OTI_MAX - 1].handlers[0 ... NUM_MACHINE_MODES - 1].insn_code
= CODE_FOR_nothing };
#else
-/* new_optab will do runtime initialization otherwise. */
+/* init_insn_codes will do runtime initialization otherwise. */
struct optab optab_table[OTI_MAX];
#endif
@@ -5564,31 +5564,38 @@ have_insn_for (enum rtx_code code, enum
!= CODE_FOR_nothing));
}
-/* Create a blank optab. */
-#if GCC_VERSION >= 4000
-static inline void
-new_optab (optab op ATTRIBUTE_UNUSED)
-{
- /* All insn_code fields are already initialized using
- designated initializers. */
-}
-#else
+/* Set all insn_code fields to CODE_FOR_nothing. */
+
static void
-new_optab (optab op)
+init_insn_codes (void)
{
- int i;
+ unsigned int i;
- for (i = 0; i < NUM_MACHINE_MODES; i++)
- optab_handler (op, i)->insn_code = CODE_FOR_nothing;
+ for (i = 0; i < (unsigned int) OTI_MAX; i++)
+ {
+ unsigned int j;
+ optab op;
+
+ op = &optab_table[i];
+ for (j = 0; j < NUM_MACHINE_MODES; j++)
+ optab_handler (op, j)->insn_code = CODE_FOR_nothing;
+ }
+ for (i = 0; i < (unsigned int) COI_MAX; i++)
+ {
+ unsigned int j, k;
+ convert_optab op;
+
+ op = &convert_optab_table[i];
+ for (j = 0; j < NUM_MACHINE_MODES; j++)
+ for (k = 0; k < NUM_MACHINE_MODES; k++)
+ convert_optab_handler (op, j, k)->insn_code = CODE_FOR_nothing;
+ }
}
-#endif
-/* Same, but fill in its code as CODE, and write it into the
- code_to_optab table. */
+/* Initialize OP's code to CODE, and write it into the code_to_optab table. */
static inline void
init_optab (optab op, enum rtx_code code)
{
- new_optab (op);
op->code = code;
code_to_optab[(int) code] = op;
}
@@ -5598,7 +5605,6 @@ init_optab (optab op, enum rtx_code code
static inline void
init_optabv (optab op, enum rtx_code code)
{
- new_optab (op);
op->code = code;
}
@@ -5606,13 +5612,6 @@ init_optabv (optab op, enum rtx_code cod
static void
init_convert_optab (convert_optab op, enum rtx_code code)
{
-#if !(GCC_VERSION >= 4000)
- int i, j;
-
- for (i = 0; i < NUM_MACHINE_MODES; i++)
- for (j = 0; j < NUM_MACHINE_MODES; j++)
- convert_optab_handler (op, i, j)->insn_code = CODE_FOR_nothing;
-#endif
op->code = code;
}
@@ -6241,6 +6240,7 @@ init_optabs (void)
{
unsigned int i;
enum machine_mode int_mode;
+ static bool reinit;
libfunc_hash = htab_create_ggc (10, hash_libfunc, eq_libfunc, NULL);
/* Start by initializing all tables to contain CODE_FOR_nothing. */
@@ -6259,6 +6259,14 @@ init_optabs (void)
vcondu_gen_code[i] = CODE_FOR_nothing;
}
+#if GCC_VERSION >= 4000
+ /* We statically initialize the insn_codes with CODE_FOR_nothing. */
+ if (reinit)
+ init_insn_codes ();
+#else
+ init_insn_codes ();
+#endif
+
init_optab (add_optab, PLUS);
init_optabv (addv_optab, PLUS);
init_optab (sub_optab, MINUS);
@@ -6736,6 +6744,8 @@ init_optabs (void)
/* Allow the target to add more libcalls or rename some, etc. */
targetm.init_libfuncs ();
+
+ reinit = true;
}
/* Print information about the current contents of the optabs on