This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Make sure that all insn codes are in (0, LAST_INSN_CODE)
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Segher Boessenkool <segher at kernel dot crashing dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 May 2014 09:41:08 +0100
- Subject: Re: Make sure that all insn codes are in (0, LAST_INSN_CODE)
- Authentication-results: sourceware.org; auth=none
- References: <87wqd8e555 dot fsf at talisman dot default> <20140526211246 dot GB31524 at gate dot crashing dot org>
Segher Boessenkool <segher@kernel.crashing.org> writes:
>> - puts (" LAST_INSN_CODE\n\
>> + printf (" LAST_INSN_CODE = %d\n\
>> };\n\
>> \n\
>> -#endif /* GCC_INSN_CODES_H */");
>> +#endif /* GCC_INSN_CODES_H */", last);
>
> You probably didn't intend to delete the newline at the end of
> the generated file?
Oops. Updated patch below.
Thanks,
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-27 09:38:02.195506710 +0100
+++ gcc/gencodes.c 2014-05-27 09:39:16.002188824 +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 */\n", last);
if (ferror (stdout) || fflush (stdout) || fclose (stdout))
return FATAL_EXIT_CODE;