+2015-08-05 Richard Sandiford <richard.sandiford@arm.com>
+
+ * gensupport.h (get_num_insn_codes): Declare.
+ * gensupport.c (get_num_insn_codes): New function.
+ * genattrtab.c (optimize_attrs): Rename max_insn_code to
+ num_insn_codes.
+ (main): Likewise. Use get_num_insn_codes.
+ * gencodes.c (main): Remove "last" and use get_num_insn_codes.
+
2015-08-05 Richard Sandiford <richard.sandiford@arm.com>
PR middle-end/66311
/* Optimize the attribute lists by seeing if we can determine conditional
values from the known values of other attributes. This will save subroutine
- calls during the compilation. MAX_INSN_CODE is the number of unique
+ calls during the compilation. NUM_INSN_CODES is the number of unique
instruction codes. */
static void
-optimize_attrs (int max_insn_code)
+optimize_attrs (int num_insn_codes)
{
struct attr_desc *attr;
struct attr_value *av;
return;
/* Make 2 extra elements, for "code" values -2 and -1. */
- insn_code_values = XCNEWVEC (struct attr_value_list *, max_insn_code + 2);
+ insn_code_values = XCNEWVEC (struct attr_value_list *, num_insn_codes + 2);
/* Offset the table address so we can index by -2 or -1. */
insn_code_values += 2;
gcc_assert (iv == ivbuf + num_insn_ents);
/* Process one insn code at a time. */
- for (i = -2; i < max_insn_code; i++)
+ for (i = -2; i < num_insn_codes; i++)
{
/* Clear the ATTR_CURR_SIMPLIFIED_P flag everywhere relevant.
We use it to mean "already simplified for this insn". */
struct attr_desc *attr;
struct insn_def *id;
int i;
- int max_insn_code = 0;
progname = "genattrtab";
}
if (GET_CODE (info.def) != DEFINE_ASM_ATTRIBUTES)
insn_index_number++;
- max_insn_code = info.index;
}
if (have_error)
return FATAL_EXIT_CODE;
- max_insn_code++;
-
/* If we didn't have a DEFINE_ASM_ATTRIBUTES, make a null one. */
if (! got_define_asm_attributes)
{
expand_delays ();
/* Make `insn_alternatives'. */
- insn_alternatives = oballocvec (uint64_t, max_insn_code);
+ int num_insn_codes = get_num_insn_codes ();
+ insn_alternatives = oballocvec (uint64_t, num_insn_codes);
for (id = defs; id; id = id->next)
if (id->insn_code >= 0)
insn_alternatives[id->insn_code]
= (((uint64_t) 1) << id->num_alternatives) - 1;
/* Make `insn_n_alternatives'. */
- insn_n_alternatives = oballocvec (int, max_insn_code);
+ insn_n_alternatives = oballocvec (int, num_insn_codes);
for (id = defs; id; id = id->next)
if (id->insn_code >= 0)
insn_n_alternatives[id->insn_code] = id->num_alternatives;
make_length_attrs ();
/* Perform any possible optimizations to speed up compilation. */
- optimize_attrs (max_insn_code);
+ optimize_attrs (num_insn_codes);
/* Now write out all the `gen_attr_...' routines. Do these before the
special routines so that they get defined before they are used. */
int
main (int argc, char **argv)
{
- int last = 1;
-
progname = "gencodes";
/* We need to see all the possibilities. Elided insns may have
case DEFINE_INSN:
case DEFINE_EXPAND:
gen_insn (&info);
- last = info.index + 1;
break;
default:
printf (" LAST_INSN_CODE = %d\n\
};\n\
\n\
-#endif /* GCC_INSN_CODES_H */\n", last);
+#endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes () - 1);
if (ferror (stdout) || fflush (stdout) || fclose (stdout))
return FATAL_EXIT_CODE;
extern bool init_rtx_reader_args_cb (int, char **, bool (*)(const char *));
extern bool init_rtx_reader_args (int, char **);
extern bool read_md_rtx (md_rtx_info *);
+extern unsigned int get_num_insn_codes ();
/* Set this to 0 to disable automatic elision of insn patterns which
can never be used in this configuration. See genconditions.c.