This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

The patch to switch off the progress bar for the DFA generator.


Zack Weinberg wrote:
> 
> Vladimir Makarov <vmakarov@redhat.com> writes:
> 
> >   Here is the patch.  It has been checked with and without usage of
> > the option.  Is it ok to commit?
> 
> As Andreas suggests, please make it emit no output at all in the
> no-progress case.  Pre-approved with that change.
> 

  Here is the modified patch.  I've comitted it into the main line.

Vlad


2004-01-13  Vladimir Makarov  <vmakarov@redhat.com>

        * rtl.def: Add comment about new option in automata_option.
        
        * genautomata.c (PROGRESS_OPTION): New macro.
        (progress_flag): New global variable.
        (gen_automata_option): Process `progress'.
        (transform_insn_regexps, check_unit_distributions_to_automata,
        make_automaton, NDFA_to_DFA, build_automaton, create_automata,
        expand_automata, write_automata): Print about the progress only
if
        progress_flag.  Remove fflush.
        (initiate_automaton_gen): Process command line flag `-progress'.

        * doc/md.texi: Describe the new option.
Index: rtl.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.def,v
retrieving revision 1.76
diff -d -c -p -r1.76 rtl.def
*** rtl.def	10 Dec 2003 07:35:47 -0000	1.76
--- rtl.def	13 Jan 2004 19:46:09 -0000
*************** DEF_RTL_EXPR(DEFINE_AUTOMATON, "define_a
*** 480,486 ****
     o "w" which means generation of warning instead of error for
       non-critical errors.
  
!    o "ndfa" which makes nondeterministic finite state automata.  */
  DEF_RTL_EXPR(AUTOMATA_OPTION, "automata_option", "s", 'x')
  
  /* (define_reservation string string) names reservation (the first
--- 480,489 ----
     o "w" which means generation of warning instead of error for
       non-critical errors.
  
!    o "ndfa" which makes nondeterministic finite state automata.
! 
!    o "progress" which means output of a progress bar showing how many
!      states were generated so far for automaton being processed.  */
  DEF_RTL_EXPR(AUTOMATA_OPTION, "automata_option", "s", 'x')
  
  /* (define_reservation string string) names reservation (the first
Index: genautomata.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/genautomata.c,v
retrieving revision 1.53
diff -d -c -p -r1.53 genautomata.c
*** genautomata.c	11 Jan 2004 00:52:18 -0000	1.53
--- genautomata.c	13 Jan 2004 19:46:09 -0000
*************** static struct obstack irp;
*** 658,663 ****
--- 658,665 ----
  
  #define NDFA_OPTION "-ndfa"
  
+ #define PROGRESS_OPTION "-progress"
+ 
  /* The following flags are set up by function `initiate_automaton_gen'.  */
  
  /* Make automata with nondeterministic reservation by insns (`-ndfa').  */
*************** static int time_flag;
*** 680,685 ****
--- 682,691 ----
     result automaton and statistics information (`-v').  */
  static int v_flag;
  
+ /* Flag of output of a progress bar showing how many states were
+    generated so far for automaton being processed (`-progress').  */
+ static int progress_flag;
+ 
  /* Flag of generating warning instead of error for non-critical errors
     (`-w').  */
  static int w_flag;
*************** gen_automata_option (rtx def)
*** 1932,1937 ****
--- 1938,1945 ----
      w_flag = 1;
    else if (strcmp (XSTR (def, 0), NDFA_OPTION + 1) == 0)
      ndfa_flag = 1;
+   else if (strcmp (XSTR (def, 0), PROGRESS_OPTION + 1) == 0)
+     progress_flag = 1;
    else
      fatal ("invalid option `%s' in automata_option", XSTR (def, 0));
  }
*************** transform_insn_regexps (void)
*** 5265,5272 ****
  
    transform_time = create_ticker ();
    add_advance_cycle_insn_decl ();
!   fprintf (stderr, "Reservation transformation...");
!   fflush (stderr);
    for (i = 0; i < description->decls_num; i++)
      {
        decl = description->decls [i];
--- 5273,5280 ----
  
    transform_time = create_ticker ();
    add_advance_cycle_insn_decl ();
!   if (progress_flag)
!     fprintf (stderr, "Reservation transformation...");
    for (i = 0; i < description->decls_num; i++)
      {
        decl = description->decls [i];
*************** transform_insn_regexps (void)
*** 5275,5283 ****
  	  = transform_regexp (copy_insn_regexp
  			      (DECL_INSN_RESERV (decl)->regexp));
      }
!   fprintf (stderr, "done\n");
    ticker_off (&transform_time);
-   fflush (stderr);
  }
  
  
--- 5283,5291 ----
  	  = transform_regexp (copy_insn_regexp
  			      (DECL_INSN_RESERV (decl)->regexp));
      }
!   if (progress_flag)
!     fprintf (stderr, "done\n");
    ticker_off (&transform_time);
  }
  
  
*************** check_unit_distributions_to_automata (vo
*** 5443,5449 ****
    decl_t decl;
    int i;
  
!   fprintf (stderr, "Check unit distributions to automata...");
    annotation_message_reported_p = FALSE;
    for (i = 0; i < description->decls_num; i++)
      {
--- 5451,5458 ----
    decl_t decl;
    int i;
  
!   if (progress_flag)
!     fprintf (stderr, "Check unit distributions to automata...");
    annotation_message_reported_p = FALSE;
    for (i = 0; i < description->decls_num; i++)
      {
*************** check_unit_distributions_to_automata (vo
*** 5453,5459 ****
  	  (DECL_INSN_RESERV (decl)->name,
  	   DECL_INSN_RESERV (decl)->transformed_regexp);
      }
!   fprintf (stderr, "done\n");
  }
  
  
--- 5462,5469 ----
  	  (DECL_INSN_RESERV (decl)->name,
  	   DECL_INSN_RESERV (decl)->transformed_regexp);
      }
!   if (progress_flag)
!     fprintf (stderr, "done\n");
  }
  
  
*************** make_automaton (automaton_t automaton)
*** 5732,5738 ****
  			      = 1;
                              VLA_PTR_ADD (state_stack, state2);
  			    states_n++;
! 			    if (states_n % 100 == 0)
  			      fprintf (stderr, ".");
                            }
  			added_arc = add_arc (state, state2, ainsn, 1);
--- 5742,5748 ----
  			      = 1;
                              VLA_PTR_ADD (state_stack, state2);
  			    states_n++;
! 			    if (progress_flag && states_n % 100 == 0)
  			      fprintf (stderr, ".");
                            }
  			added_arc = add_arc (state, state2, ainsn, 1);
*************** make_automaton (automaton_t automaton)
*** 5763,5769 ****
            state2->it_was_placed_in_stack_for_NDFA_forming = 1;
            VLA_PTR_ADD (state_stack, state2);
  	  states_n++;
! 	  if (states_n % 100 == 0)
  	    fprintf (stderr, ".");
          }
        if (advance_cycle_ainsn == NULL)
--- 5773,5779 ----
            state2->it_was_placed_in_stack_for_NDFA_forming = 1;
            VLA_PTR_ADD (state_stack, state2);
  	  states_n++;
! 	  if (progress_flag && states_n % 100 == 0)
  	    fprintf (stderr, ".");
          }
        if (advance_cycle_ainsn == NULL)
*************** NDFA_to_DFA (automaton_t automaton)
*** 5934,5940 ****
  		  &state_stack))
  	    {
  	      states_n++;
! 	      if (states_n % 100 == 0)
  		fprintf (stderr, ".");
  	    }
  	}
--- 5944,5950 ----
  		  &state_stack))
  	    {
  	      states_n++;
! 	      if (progress_flag && states_n % 100 == 0)
  		fprintf (stderr, ".");
  	    }
  	}
*************** build_automaton (automaton_t automaton)
*** 6395,6419 ****
    int arcs_num;
  
    ticker_on (&NDFA_time);
!   if (automaton->corresponding_automaton_decl == NULL)
!     fprintf (stderr, "Create anonymous automaton (1 dot is 100 new states):");
!   else
!     fprintf (stderr, "Create automaton `%s' (1 dot is 100 new states):",
! 	     automaton->corresponding_automaton_decl->name);
    make_automaton (automaton);
!   fprintf (stderr, " done\n");
    ticker_off (&NDFA_time);
    count_states_and_arcs (automaton, &states_num, &arcs_num);
    automaton->NDFA_states_num = states_num;
    automaton->NDFA_arcs_num = arcs_num;
    ticker_on (&NDFA_to_DFA_time);
!   if (automaton->corresponding_automaton_decl == NULL)
!     fprintf (stderr, "Make anonymous DFA (1 dot is 100 new states):");
!   else
!     fprintf (stderr, "Make DFA `%s' (1 dot is 100 new states):",
! 	     automaton->corresponding_automaton_decl->name);
    NDFA_to_DFA (automaton);
!   fprintf (stderr, " done\n");
    ticker_off (&NDFA_to_DFA_time);
    count_states_and_arcs (automaton, &states_num, &arcs_num);
    automaton->DFA_states_num = states_num;
--- 6405,6439 ----
    int arcs_num;
  
    ticker_on (&NDFA_time);
!   if (progress_flag)
!     {
!       if (automaton->corresponding_automaton_decl == NULL)
! 	fprintf (stderr, "Create anonymous automaton");
!       else
! 	fprintf (stderr, "Create automaton `%s'",
! 		 automaton->corresponding_automaton_decl->name);
!       fprintf (stderr, " (1 dot is 100 new states):");
!     }
    make_automaton (automaton);
!   if (progress_flag)
!     fprintf (stderr, " done\n");
    ticker_off (&NDFA_time);
    count_states_and_arcs (automaton, &states_num, &arcs_num);
    automaton->NDFA_states_num = states_num;
    automaton->NDFA_arcs_num = arcs_num;
    ticker_on (&NDFA_to_DFA_time);
!   if (progress_flag)
!     {
!       if (automaton->corresponding_automaton_decl == NULL)
! 	fprintf (stderr, "Make anonymous DFA");
!       else
! 	fprintf (stderr, "Make DFA `%s'",
! 		 automaton->corresponding_automaton_decl->name);
!       fprintf (stderr, " (1 dot is 100 new states):");
!     }
    NDFA_to_DFA (automaton);
!   if (progress_flag)
!     fprintf (stderr, " done\n");
    ticker_off (&NDFA_to_DFA_time);
    count_states_and_arcs (automaton, &states_num, &arcs_num);
    automaton->DFA_states_num = states_num;
*************** build_automaton (automaton_t automaton)
*** 6421,6433 ****
    if (!no_minimization_flag)
      {
        ticker_on (&minimize_time);
!       if (automaton->corresponding_automaton_decl == NULL)
! 	fprintf (stderr, "Minimize anonymous DFA...");
!       else
! 	fprintf (stderr, "Minimize DFA `%s'...",
! 		 automaton->corresponding_automaton_decl->name);
        minimize_DFA (automaton);
!       fprintf (stderr, "done\n");
        ticker_off (&minimize_time);
        count_states_and_arcs (automaton, &states_num, &arcs_num);
        automaton->minimal_DFA_states_num = states_num;
--- 6441,6457 ----
    if (!no_minimization_flag)
      {
        ticker_on (&minimize_time);
!       if (progress_flag)
! 	{
! 	  if (automaton->corresponding_automaton_decl == NULL)
! 	    fprintf (stderr, "Minimize anonymous DFA...");
! 	  else
! 	    fprintf (stderr, "Minimize DFA `%s'...",
! 		     automaton->corresponding_automaton_decl->name);
! 	}
        minimize_DFA (automaton);
!       if (progress_flag)
! 	fprintf (stderr, "done\n");
        ticker_off (&minimize_time);
        count_states_and_arcs (automaton, &states_num, &arcs_num);
        automaton->minimal_DFA_states_num = states_num;
*************** create_automata (void)
*** 6851,6864 ****
         curr_automaton != NULL;
         curr_automaton = curr_automaton->next_automaton)
      {
!       if (curr_automaton->corresponding_automaton_decl == NULL)
! 	fprintf (stderr, "Prepare anonymous automaton creation ... ");
!       else
! 	fprintf (stderr, "Prepare automaton `%s' creation...",
! 		 curr_automaton->corresponding_automaton_decl->name);
        create_alt_states (curr_automaton);
        form_ainsn_with_same_reservs (curr_automaton);
!       fprintf (stderr, "done\n");
        build_automaton (curr_automaton);
        enumerate_states (curr_automaton);
        ticker_on (&equiv_time);
--- 6875,6892 ----
         curr_automaton != NULL;
         curr_automaton = curr_automaton->next_automaton)
      {
!       if (progress_flag)
! 	{
! 	  if (curr_automaton->corresponding_automaton_decl == NULL)
! 	    fprintf (stderr, "Prepare anonymous automaton creation ... ");
! 	  else
! 	    fprintf (stderr, "Prepare automaton `%s' creation...",
! 		     curr_automaton->corresponding_automaton_decl->name);
! 	}
        create_alt_states (curr_automaton);
        form_ainsn_with_same_reservs (curr_automaton);
!       if (progress_flag)
! 	fprintf (stderr, "done\n");
        build_automaton (curr_automaton);
        enumerate_states (curr_automaton);
        ticker_on (&equiv_time);
*************** initiate_automaton_gen (int argc, char *
*** 9615,9620 ****
--- 9643,9649 ----
    time_flag = 0;
    v_flag = 0;
    w_flag = 0;
+   progress_flag = 0;
    for (i = 2; i < argc; i++)
      if (strcmp (argv [i], NO_MINIMIZATION_OPTION) == 0)
        no_minimization_flag = 1;
*************** initiate_automaton_gen (int argc, char *
*** 9626,9631 ****
--- 9655,9662 ----
        w_flag = 1;
      else if (strcmp (argv [i], NDFA_OPTION) == 0)
        ndfa_flag = 1;
+     else if (strcmp (argv [i], PROGRESS_OPTION) == 0)
+       progress_flag = 1;
      else if (strcmp (argv [i], "-split") == 0)
        {
  	if (i + 1 >= argc)
*************** expand_automata (void)
*** 9796,9805 ****
      }
    all_time = create_ticker ();
    check_time = create_ticker ();
!   fprintf (stderr, "Check description...");
!   fflush (stderr);
    check_all_description ();
!   fprintf (stderr, "done\n");
    ticker_off (&check_time);
    generation_time = create_ticker ();
    if (!have_error)
--- 9827,9837 ----
      }
    all_time = create_ticker ();
    check_time = create_ticker ();
!   if (progress_flag)
!     fprintf (stderr, "Check description...");
    check_all_description ();
!   if (progress_flag)
!     fprintf (stderr, "done\n");
    ticker_off (&check_time);
    generation_time = create_ticker ();
    if (!have_error)
*************** expand_automata (void)
*** 9815,9832 ****
    if (!have_error)
      {
        form_important_insn_automata_lists ();
!       fprintf (stderr, "Generation of attributes...");
!       fflush (stderr);
        make_internal_dfa_insn_code_attr ();
        make_insn_alts_attr ();
        make_default_insn_latency_attr ();
        make_bypass_attr ();
!       fprintf (stderr, "done\n");
      }
    ticker_off (&generation_time);
    ticker_off (&all_time);
!   fprintf (stderr, "All other genattrtab stuff...");
!   fflush (stderr);
  }
  
  /* The following is top level function to output PHR and to finish
--- 9847,9865 ----
    if (!have_error)
      {
        form_important_insn_automata_lists ();
!       if (progress_flag)
! 	fprintf (stderr, "Generation of attributes...");
        make_internal_dfa_insn_code_attr ();
        make_insn_alts_attr ();
        make_default_insn_latency_attr ();
        make_bypass_attr ();
!       if (progress_flag)
! 	fprintf (stderr, "done\n");
      }
    ticker_off (&generation_time);
    ticker_off (&all_time);
!   if (progress_flag)
!     fprintf (stderr, "All other genattrtab stuff...");
  }
  
  /* The following is top level function to output PHR and to finish
*************** expand_automata (void)
*** 9834,9851 ****
  void
  write_automata (void)
  {
!   fprintf (stderr, "done\n");
    if (have_error)
      fatal ("Errors in DFA description");
    ticker_on (&all_time);
    output_time = create_ticker ();
!   fprintf (stderr, "Forming and outputting automata tables...");
!   fflush (stderr);
    output_dfa_max_issue_rate ();
    output_tables ();
!   fprintf (stderr, "done\n");
!   fprintf (stderr, "Output functions to work with automata...");
!   fflush (stderr);
    output_chip_definitions ();
    output_max_insn_queue_index_def ();
    output_internal_min_issue_delay_func ();
--- 9867,9887 ----
  void
  write_automata (void)
  {
!   if (progress_flag)
!     fprintf (stderr, "done\n");
    if (have_error)
      fatal ("Errors in DFA description");
    ticker_on (&all_time);
    output_time = create_ticker ();
!   if (progress_flag)
!     fprintf (stderr, "Forming and outputting automata tables...");
    output_dfa_max_issue_rate ();
    output_tables ();
!   if (progress_flag)
!     {
!       fprintf (stderr, "done\n");
!       fprintf (stderr, "Output functions to work with automata...");
!     }
    output_chip_definitions ();
    output_max_insn_queue_index_def ();
    output_internal_min_issue_delay_func ();
*************** write_automata (void)
*** 9880,9886 ****
    output_dfa_clean_insn_cache_func ();
    output_dfa_start_func ();
    output_dfa_finish_func ();
!   fprintf (stderr, "done\n");
    if (v_flag)
      {
        output_description_file = fopen (output_description_file_name, "w");
--- 9916,9923 ----
    output_dfa_clean_insn_cache_func ();
    output_dfa_start_func ();
    output_dfa_finish_func ();
!   if (progress_flag)
!     fprintf (stderr, "done\n");
    if (v_flag)
      {
        output_description_file = fopen (output_description_file_name, "w");
*************** write_automata (void)
*** 9889,9899 ****
  	  perror (output_description_file_name);
  	  exit (FATAL_EXIT_CODE);
  	}
!       fprintf (stderr, "Output automata description...");
!       fflush (stderr);
        output_description ();
        output_automaton_descriptions ();
!       fprintf (stderr, "done\n");
        output_statistics (output_description_file);
      }
    output_statistics (stderr);
--- 9926,9937 ----
  	  perror (output_description_file_name);
  	  exit (FATAL_EXIT_CODE);
  	}
!       if (progress_flag)
! 	fprintf (stderr, "Output automata description...");
        output_description ();
        output_automaton_descriptions ();
!       if (progress_flag)
! 	fprintf (stderr, "done\n");
        output_statistics (output_description_file);
      }
    output_statistics (stderr);
Index: doc/md.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/md.texi,v
retrieving revision 1.83
diff -d -c -p -r1.83 md.texi
*** doc/md.texi	9 Jan 2004 15:33:47 -0000	1.83
--- doc/md.texi	13 Jan 2004 19:46:09 -0000
*************** nondeterministic treatment means trying 
*** 5999,6004 ****
--- 5999,6012 ----
  may be rejected by reservations in the subsequent insns.  You can not
  query functional unit reservations in nondeterministic automaton
  states.
+ 
+ @item
+ @dfn{progress} means output of a progress bar showing how many states
+ were generated so far for automaton being processed.  This is useful
+ during debugging a @acronym{DFA} description.  If you see too many
+ generated states, you could interrupt the generator of the pipeline
+ hazard recognizer and try to figure out a reason for generation of the
+ huge automaton.
  @end itemize
  
  As an example, consider a superscalar @acronym{RISC} machine which can

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]