[patch 6/9] genautomata chainsaw pass 1
Zack Weinberg
zackw@panix.com
Sat Jan 7 06:39:00 GMT 2006
Okay, this is entirely tangential cleanups in genautomata and the code
it generates. MAX_DFA_ISSUE_RATE is used nowhere, so kill it; so
there is no point in emitting a dead_lock_vect full of zeroes for
automata that have none (which is the normal case). Also,
length_unit_log and max_insn_queue_index are never modified, so make
them const.
zw
* genautomata.c (process_state_longest_path, max_dfa_issue_rate)
(output_dfa_max_issue_rate, locked_states_num): Delete.
(struct automaton): Add locked_states field.
(output_dead_lock_vect): Save number of locked states in
automaton->locked_states. If it is zero, don't print anything.
(output_max_insn_queue_index_def): Define max_insn_queue_index const.
(output_internal_dead_lock_func): Only test the dead_lock_vect
for automata that have locked states.
(output_statistics): Always print the number of locked states for
each automaton. Calculate total number of locked states here.
(write_automata): Don't call output_dfa_max_issue_rate.
* genattrtab.c: Define length_unit_log as a const variable.
* genattr.c: Don't emit MAX_DFA_ISSUE_RATE. Declare
max_insn_queue_index const.
* final.c (length_unit_log): Declare const.
* doc/tm.texi: Remove all references to MAX_DFA_ISSUE_RATE.
==================================================================
--- doc/tm.texi (revision 108720)
+++ doc/tm.texi (revision 108721)
@@ -5581,9 +5581,6 @@
This value must be constant over the entire compilation. If you need
it to vary depending on what the instructions are, you must use
@samp{TARGET_SCHED_VARIABLE_ISSUE}.
-You could define this hook to return the value of the macro
-@code{MAX_DFA_ISSUE_RATE}.
@end deftypefn
@deftypefn {Target Hook} int TARGET_SCHED_VARIABLE_ISSUE (FILE *@var{file}, int @var{verbose}, rtx @var{insn}, int @var{more})
@@ -5793,17 +5790,6 @@
not in cases of "costly dependences", which this hooks allows to define.
@end deftypefn
-Macros in the following table are generated by the program
-@file{genattr} and can be useful for writing the hooks.
-@defmac MAX_DFA_ISSUE_RATE
-The macro definition is generated in the automaton based pipeline
-description interface. Its value is calculated from the automaton
-based pipeline description and is equal to maximal number of all insns
-described in constructions @samp{define_insn_reservation} which can be
-issued on the same processor cycle.
-@end defmac
@node Sections
@section Dividing the Output into Sections (Texts, Data, @dots{})
@c the above section title is WAY too long. maybe cut the part between
==================================================================
--- final.c (revision 108720)
+++ final.c (revision 108721)
@@ -144,7 +144,7 @@
/* Whether to force emission of a line note before the next insn. */
static bool force_source_line = false;
-extern int length_unit_log; /* This is defined in insn-attrtab.c. */
+extern const int length_unit_log; /* This is defined in insn-attrtab.c. */
/* Nonzero while outputting an `asm' with operands.
This means that inconsistencies are the user's fault, so don't die.
==================================================================
--- genautomata.c (revision 108720)
+++ genautomata.c (revision 108721)
@@ -414,8 +414,6 @@
static void output_range_type (FILE *, long int, long int);
static int longest_path_length (state_t);
-static void process_state_longest_path_length (state_t);
-static void output_dfa_max_issue_rate (void);
static void output_chip_member_name (FILE *, automaton_t);
static void output_temp_chip_member_name (FILE *, automaton_t);
static void output_translate_vect_name (FILE *, automaton_t);
@@ -1155,6 +1153,8 @@
8) elements in one vector element. So the compression factor can
be 1 (no compression), 2, 4, 8. */
int min_issue_delay_table_compression_factor;
+ /* Total number of locked states in this automaton. */
+ int locked_states;
};
/* The following is the element of the list of automata. */
@@ -7015,47 +7015,6 @@
return result;
}
-/* The following variable value is value of the corresponding global
- variable in the automaton based pipeline interface. */
-static int max_dfa_issue_rate;
-/* The following function processes the longest path length staring
- from STATE to find MAX_DFA_ISSUE_RATE. */
-static void
-process_state_longest_path_length (state_t state)
-{
- int value;
- value = longest_path_length (state);
- if (value > max_dfa_issue_rate)
- max_dfa_issue_rate = value;
-}
-/* The following macro value is name of the corresponding global
- variable in the automaton based pipeline interface. */
-#define MAX_DFA_ISSUE_RATE_VAR_NAME "max_dfa_issue_rate"
-/* The following function calculates value of the corresponding
- global variable and outputs its declaration. */
-static void
-output_dfa_max_issue_rate (void)
-{
- automaton_t automaton;
- gcc_assert (UNDEFINED_LONGEST_PATH_LENGTH != ON_THE_PATH && ON_THE_PATH < 0);
- max_dfa_issue_rate = 0;
- for (automaton = description->first_automaton;
- automaton != NULL;
- automaton = automaton->next_automaton)
- pass_states (automaton, process_state_longest_path_length);
- fprintf (output_file, "\nint %s = %d;\n",
- MAX_DFA_ISSUE_RATE_VAR_NAME, max_dfa_issue_rate);
-}
/* The function outputs all initialization values of VECT. */
static void
output_vect (vla_hwint_t vect)
@@ -7977,12 +7936,6 @@
VEC_free (vect_el_t,heap, compressed_min_issue_delay_vect);
}
-#ifndef NDEBUG
-/* Number of states which contains transition only by advancing cpu
- cycle. */
-static int locked_states_num;
-#endif
/* Form and output vector representing the locked states of
AUTOMATON. */
static void
@@ -7995,6 +7948,7 @@
/* Create vect of pointers to states ordered by num of
transitions from the state (state with the maximum num is the
first). */
+ automaton->locked_states = 0;
output_states_vect = 0;
pass_states (automaton, add_states_vect_el);
@@ -8005,16 +7959,19 @@
state_t s = VEC_index (state_t, output_states_vect, i);
arc = first_out_arc (s);
gcc_assert (arc);
- VEC_replace (vect_el_t, dead_lock_vect, s->order_state_num,
- (next_out_arc (arc) == NULL
- && (arc->insn->insn_reserv_decl
- == DECL_INSN_RESERV (advance_cycle_insn_decl))
- ? 1 : 0));
-#ifndef NDEBUG
- if (VEC_index (vect_el_t,dead_lock_vect, s->order_state_num))
- locked_states_num++;
-#endif
+ if (next_out_arc (arc) == NULL
+ && (arc->insn->insn_reserv_decl
+ == DECL_INSN_RESERV (advance_cycle_insn_decl)))
+ {
+ VEC_replace (vect_el_t, dead_lock_vect, s->order_state_num, 1);
+ automaton->locked_states++;
+ }
+ else
+ VEC_replace (vect_el_t, dead_lock_vect, s->order_state_num, 0);
}
+ if (automaton->locked_states == 0)
+ return;
+
fprintf (output_file, "/* Vector for locked state flags. */\n");
fprintf (output_file, "static const ");
output_range_type (output_file, 0, 1);
@@ -8085,9 +8042,6 @@
{
automaton_t automaton;
-#ifndef NDEBUG
- locked_states_num = 0;
-#endif
initiate_min_issue_delay_pass_states ();
for (automaton = description->first_automaton;
automaton != NULL;
@@ -8139,10 +8093,10 @@
for (i = 0; (1 << i) <= max; i++)
;
gcc_assert (i >= 0);
- fprintf (output_file, "\nint max_insn_queue_index = %d;\n\n", (1 << i) - 1);
+ fprintf (output_file, "\nconst int max_insn_queue_index = %d;\n\n",
+ (1 << i) - 1);
}
/* The function outputs switch cases for insn reservations using
function *output_automata_list_code. */
static void
@@ -8575,19 +8529,20 @@
{
automaton_t automaton;
- fprintf (output_file, "static int\n%s (struct %s *%s)\n",
+ fprintf (output_file, "static int\n%s (struct %s *ARG_UNUSED (%s))\n",
INTERNAL_DEAD_LOCK_FUNC_NAME, CHIP_NAME, CHIP_PARAMETER_NAME);
fprintf (output_file, "{\n");
for (automaton = description->first_automaton;
automaton != NULL;
automaton = automaton->next_automaton)
- {
- fprintf (output_file, " if (");
- output_dead_lock_vect_name (output_file, automaton);
- fprintf (output_file, " [%s->", CHIP_PARAMETER_NAME);
- output_chip_member_name (output_file, automaton);
- fprintf (output_file, "])\n return 1/* TRUE */;\n");
- }
+ if (automaton->locked_states)
+ {
+ fprintf (output_file, " if (");
+ output_dead_lock_vect_name (output_file, automaton);
+ fprintf (output_file, " [%s->", CHIP_PARAMETER_NAME);
+ output_chip_member_name (output_file, automaton);
+ fprintf (output_file, "])\n return 1/* TRUE */;\n");
+ }
fprintf (output_file, " return 0/* FALSE */;\n}\n\n");
}
@@ -9314,6 +9269,7 @@
int state_alts_comb_vect_els = 0;
int state_alts_full_vect_els = 0;
int min_issue_delay_vect_els = 0;
+ int locked_states = 0;
#endif
for (automaton = description->first_automaton;
@@ -9336,6 +9292,7 @@
}
fprintf (f, " %5d all insns %5d insn equivalence classes\n",
description->insns_num, automaton->insn_equiv_classes_num);
+ fprintf (f, " %d locked states\n", automaton->locked_states);
#ifndef NDEBUG
fprintf
(f, "%5ld transition comb vector els, %5ld trans table els: %s\n",
@@ -9363,6 +9320,8 @@
+= VEC_length (vect_el_t, automaton->state_alts_table->full_vect);
min_issue_delay_vect_els
+= states_num * automaton->insn_equiv_classes_num;
+ locked_states
+ += automaton->locked_states;
#endif
}
#ifndef NDEBUG
@@ -9376,7 +9335,7 @@
(f, "%5d all state alts comb vector els, %5d all state alts table els\n",
state_alts_comb_vect_els, state_alts_full_vect_els);
fprintf (f, "%5d all min delay table els\n", min_issue_delay_vect_els);
- fprintf (f, "%5d locked states num\n", locked_states_num);
+ fprintf (f, "%5d all locked states\n", locked_states);
#endif
}
@@ -9865,7 +9824,6 @@
output_time = create_ticker ();
if (progress_flag)
fprintf (stderr, "Forming and outputting automata tables...");
- output_dfa_max_issue_rate ();
output_tables ();
if (progress_flag)
{
==================================================================
--- genattrtab.c (revision 108720)
+++ genattrtab.c (revision 108721)
@@ -1690,7 +1690,7 @@
for (length_unit_log = 0; length_or & 1; length_or >>= 1)
length_unit_log++;
}
- printf ("int length_unit_log = %u;\n", length_unit_log);
+ printf ("const int length_unit_log = %u;\n", length_unit_log);
}
/* Take a COND expression and see if any of the conditions in it can be
==================================================================
--- genattr.c (revision 108720)
+++ genattr.c (revision 108721)
@@ -174,13 +174,6 @@
printf ("#define CPU_UNITS_QUERY 0\n");
printf ("#endif\n\n");
/* Interface itself: */
- printf ("extern int max_dfa_issue_rate;\n\n");
- printf ("/* The following macro value is calculated from the\n");
- printf (" automaton based pipeline description and is equal to\n");
- printf (" maximal number of all insns described in constructions\n");
- printf (" `define_insn_reservation' which can be issued on the\n");
- printf (" same processor cycle. */\n");
- printf ("#define MAX_DFA_ISSUE_RATE max_dfa_issue_rate\n\n");
printf ("/* Insn latency time defined in define_insn_reservation. */\n");
printf ("extern int insn_default_latency (rtx);\n\n");
printf ("/* Return nonzero if there is a bypass for given insn\n");
@@ -198,7 +191,7 @@
printf ("#endif\n\n");
printf ("/* Maximal possible number of insns waiting results being\n");
printf (" produced by insns whose execution is not finished. */\n");
- printf ("extern int max_insn_queue_index;\n\n");
+ printf ("extern const int max_insn_queue_index;\n\n");
printf ("/* Pointer to data describing current state of DFA. */\n");
printf ("typedef void *state_t;\n\n");
printf ("/* Size of the data in bytes. */\n");
More information about the Gcc-patches
mailing list