public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix genautomata option parsing
@ 2012-01-27 17:21 Bernd Schmidt
  2012-01-27 18:56 ` Vladimir Makarov
  0 siblings, 1 reply; 2+ messages in thread
From: Bernd Schmidt @ 2012-01-27 17:21 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 368 bytes --]

I noticed that genautomata does not accept any of the options it is
trying to handle, since init_rtx_reader_args already errors out for all
of them. This was probably broken by some gensupport reorganization way
back.

Fixed with this patch; I also removed the zero initializations for the
flags which ought to be unnecessary.

Bootstrapped on i686-linux. Ok?


Bernd

[-- Attachment #2: ga-opts.diff --]
[-- Type: text/plain, Size: 3228 bytes --]

	* genautomata.c (parse_automata_opt): New static function.
	(initiate_automaton_gen): Remove all option handling code.  Remove
	argc argument.  All callers changed.
	(main): Call init_rtx_reader_args_cb with the new function as
	argument.

Index: gcc/genautomata.c
===================================================================
--- gcc/genautomata.c	(revision 182544)
+++ gcc/genautomata.c	(working copy)
@@ -9285,46 +9285,45 @@ base_file_name (const char *file_name)
   return file_name + directory_name_length + 1;
 }
 
+/* A function passed as argument to init_rtx_reader_args_cb.  It parses the
+   options available for genautomata.  Returns true if the option was
+   recognized.  */
+static bool
+parse_automata_opt (const char *str)
+{
+  if (strcmp (str, NO_MINIMIZATION_OPTION) == 0)
+    no_minimization_flag = 1;
+  else if (strcmp (str, TIME_OPTION) == 0)
+    time_flag = 1;
+  else if (strcmp (str, STATS_OPTION) == 0)
+    stats_flag = 1;
+  else if (strcmp (str, V_OPTION) == 0)
+    v_flag = 1;
+  else if (strcmp (str, W_OPTION) == 0)
+    w_flag = 1;
+  else if (strcmp (str, NDFA_OPTION) == 0)
+    ndfa_flag = 1;
+  else if (strcmp (str, COLLAPSE_OPTION) == 0)
+    collapse_flag = 1;
+  else if (strcmp (str, PROGRESS_OPTION) == 0)
+    progress_flag = 1;
+  else if (strcmp (str, "-split") == 0)
+    {
+      fatal ("option `-split' has not been implemented yet\n");
+      /* split_argument = atoi (argument_vect [i + 1]); */
+    }
+  else
+    return false;
+
+  return true;
+}
+
 /* The following is top level function to initialize the work of
    pipeline hazards description translator.  */
 static void
-initiate_automaton_gen (int argc, char **argv)
+initiate_automaton_gen (char **argv)
 {
   const char *base_name;
-  int i;
-
-  ndfa_flag = 0;
-  split_argument = 0;  /* default value */
-  no_minimization_flag = 0;
-  time_flag = 0;
-  stats_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;
-    else if (strcmp (argv [i], TIME_OPTION) == 0)
-      time_flag = 1;
-    else if (strcmp (argv [i], STATS_OPTION) == 0)
-      stats_flag = 1;
-    else if (strcmp (argv [i], V_OPTION) == 0)
-      v_flag = 1;
-    else if (strcmp (argv [i], W_OPTION) == 0)
-      w_flag = 1;
-    else if (strcmp (argv [i], NDFA_OPTION) == 0)
-      ndfa_flag = 1;
-    else if (strcmp (argv [i], COLLAPSE_OPTION) == 0)
-      collapse_flag = 1;
-    else if (strcmp (argv [i], PROGRESS_OPTION) == 0)
-      progress_flag = 1;
-    else if (strcmp (argv [i], "-split") == 0)
-      {
-	if (i + 1 >= argc)
-	  fatal ("-split has no argument.");
-	fatal ("option `-split' has not been implemented yet\n");
-	/* split_argument = atoi (argument_vect [i + 1]); */
-      }
 
   /* Initialize IR storage.  */
   obstack_init (&irp);
@@ -9620,10 +9619,10 @@ main (int argc, char **argv)
 
   progname = "genautomata";
 
-  if (!init_rtx_reader_args (argc, argv))
+  if (!init_rtx_reader_args_cb (argc, argv, parse_automata_opt))
     return (FATAL_EXIT_CODE);
 
-  initiate_automaton_gen (argc, argv);
+  initiate_automaton_gen (argv);
   while (1)
     {
       int lineno;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fix genautomata option parsing
  2012-01-27 17:21 Fix genautomata option parsing Bernd Schmidt
@ 2012-01-27 18:56 ` Vladimir Makarov
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Makarov @ 2012-01-27 18:56 UTC (permalink / raw)
  To: Bernd Schmidt; +Cc: GCC Patches

On 01/27/2012 12:20 PM, Bernd Schmidt wrote:
> I noticed that genautomata does not accept any of the options it is
> trying to handle, since init_rtx_reader_args already errors out for all
> of them. This was probably broken by some gensupport reorganization way
> back.
>
> Fixed with this patch; I also removed the zero initializations for the
> flags which ought to be unnecessary.
>
> Bootstrapped on i686-linux. Ok?
>
>
Ok.  Thanks, Bernd.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-27 18:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-27 17:21 Fix genautomata option parsing Bernd Schmidt
2012-01-27 18:56 ` Vladimir Makarov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).