From: Richard Sandiford Date: Wed, 5 Aug 2015 15:44:23 +0000 (+0000) Subject: gensupport.h (get_num_insn_codes): Declare. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba0ee63dfe37e08aef608039525304e919c18187;p=gcc.git gensupport.h (get_num_insn_codes): Declare. gcc/ * 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. From-SVN: r226633 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7643309d29b..ac7b170932f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2015-08-05 Richard Sandiford + + * 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 PR middle-end/66311 diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c index 1f57c360418..932b18b1237 100644 --- a/gcc/genattrtab.c +++ b/gcc/genattrtab.c @@ -2952,11 +2952,11 @@ get_attr_order (struct attr_desc ***ret) /* 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; @@ -2975,7 +2975,7 @@ optimize_attrs (int max_insn_code) 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; @@ -3003,7 +3003,7 @@ optimize_attrs (int max_insn_code) 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". */ @@ -5161,7 +5161,6 @@ main (int argc, char **argv) struct attr_desc *attr; struct insn_def *id; int i; - int max_insn_code = 0; progname = "genattrtab"; @@ -5224,14 +5223,11 @@ main (int argc, char **argv) } 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) { @@ -5248,14 +5244,15 @@ main (int argc, char **argv) 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; @@ -5284,7 +5281,7 @@ main (int argc, char **argv) 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. */ diff --git a/gcc/gencodes.c b/gcc/gencodes.c index b9d65a2c8bc..c7478912e9b 100644 --- a/gcc/gencodes.c +++ b/gcc/gencodes.c @@ -49,8 +49,6 @@ gen_insn (md_rtx_info *info) int main (int argc, char **argv) { - int last = 1; - progname = "gencodes"; /* We need to see all the possibilities. Elided insns may have @@ -79,7 +77,6 @@ enum insn_code {\n\ case DEFINE_INSN: case DEFINE_EXPAND: gen_insn (&info); - last = info.index + 1; break; default: @@ -89,7 +86,7 @@ enum insn_code {\n\ 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; diff --git a/gcc/gensupport.c b/gcc/gensupport.c index b7681a234c1..714af03dc56 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -2602,6 +2602,14 @@ read_md_rtx (md_rtx_info *info) return true; } +/* Return the number of possible INSN_CODEs. Only meaningful once the + whole file has been processed. */ +unsigned int +get_num_insn_codes () +{ + return sequence_num; +} + /* Helper functions for insn elision. */ /* Compute a hash function of a c_test structure, which is keyed diff --git a/gcc/gensupport.h b/gcc/gensupport.h index 8fbdb364bcd..c37ec367c53 100644 --- a/gcc/gensupport.h +++ b/gcc/gensupport.h @@ -43,6 +43,7 @@ extern rtx add_implicit_parallel (rtvec); 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.