This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Make sure that all insn codes are in (0, LAST_INSN_CODE)
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 26 May 2014 20:01:10 +0100
- Subject: Make sure that all insn codes are in (0, LAST_INSN_CODE)
- Authentication-results: sourceware.org; auth=none
The patches I posted to cache recog_op_alt and the set of enabled
alternatives both relied on having an array of LAST_INSN_CODE elements.
It turns out that LAST_INSN_CODE is only 1+ the last _named_ insn,
rather than 1+ the last used insn code.
The only users of LAST_INSN_CODE I can see are LRA, which also uses it
for a per-insn-code cache, and tree-vect-stmts.c, which uses it as a
code that no insn can have. In both cases I think we want LAST_INSN_CODE
to account for unnamed insns too.
Tested on x86_64-linux-gnu. OK to install?
Richard
gcc/
* gencodes.c (main): Make LAST_INSN_CODE higher than any insn code,
rather than any named insn's code.
Index: gcc/gencodes.c
===================================================================
--- gcc/gencodes.c 2014-05-25 14:07:53.024841792 +0100
+++ gcc/gencodes.c 2014-05-25 14:17:28.905958781 +0100
@@ -50,6 +50,7 @@ gen_insn (rtx insn, int code)
main (int argc, char **argv)
{
rtx desc;
+ int last = 1;
progname = "gencodes";
@@ -82,13 +83,16 @@ enum insn_code {\n\
break;
if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND)
- gen_insn (desc, insn_code_number);
+ {
+ gen_insn (desc, insn_code_number);
+ last = insn_code_number + 1;
+ }
}
- puts (" LAST_INSN_CODE\n\
+ printf (" LAST_INSN_CODE = %d\n\
};\n\
\n\
-#endif /* GCC_INSN_CODES_H */");
+#endif /* GCC_INSN_CODES_H */", last);
if (ferror (stdout) || fflush (stdout) || fclose (stdout))
return FATAL_EXIT_CODE;