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]

[cs] new init_once langhook patch


I've checked this into the compile-server branch.
I haven't tested it by itself, though it seems likely
that it would also work on the trunk.

This adds a new lang hook for "once" initialization.
It also renames the init hook to init_eachsrc, following
the new naming convention, but I didn't change the
LANG_HOOKS_INIT macro since that would require changing
all the front-end.

The patch also includes some initial changes to toplev.c
to separate out appropriate stuff in init_compile_once,
including calling the new call-back.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


2003-08-14  Per Bothner  <pbothner@apple.com>

	* langhooks.h (struct lang_hooks):  New hook init_once.
	Renamed init hook init_eachsrc.
	* toplev.c (lang_dependent_init):  Update hook call.
	* langhooks-def.h (LANG_HOOKS_INIT_ONCE):  New macros.
	(LANG_HOOKS_INITIALIZER):  Add LANG_HOOKS_INIT_ONCE.
	* toplev.c (init_compile_once):  New function, split from do_compile.
	(backend_init):  Move init_emit_once call to init_compile_once.
	(do_compile):  Move process_options call to init_compile_once.
	(init_compile_once);  Call init_once hook.
	(toplev_main):  Call init_compiel_once before do_compile.

Index: langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.66.2.1
diff -u -p -r1.66.2.1 langhooks.h
--- langhooks.h	12 Aug 2003 23:06:59 -0000	1.66.2.1
+++ langhooks.h	14 Aug 2003 20:22:13 -0000
@@ -231,10 +231,15 @@ struct lang_hooks
      immediately and the finish hook is not called.  */
   bool (*post_options) (const char **);
 
-  /* Called after post_options to initialize the front end.  Return
-     false to indicate that no further compilation be performed, in
-     which case the finish hook is called immediately.  */
-  bool (*init) (void);
+  /* Called after post_options, to initialize the front end.
+     This only gets called once, even if we're invoked as a server. */
+  void (*init_once) PARAMS ((void));
+
+  /* Called (after init_once) to initialize the front-end for a main file.
+     If we're invoked as a server, this is called once for each request.
+     Return false to indicate that no further compilation be performed,
+     in which case the finish hook is called immediately.  */
+  bool (*init_eachsrc) (void);
 
   /* Called at the end of compilation, as a finalizer.  */
   void (*finish) (void);
Index: langhooks-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v
retrieving revision 1.57.2.1
diff -u -p -r1.57.2.1 langhooks-def.h
--- langhooks-def.h	12 Aug 2003 23:06:59 -0000	1.57.2.1
+++ langhooks-def.h	14 Aug 2003 20:22:13 -0000
@@ -83,6 +83,7 @@ extern void lhd_initialize_diagnostics (
 
 #define LANG_HOOKS_NAME			"GNU unknown"
 #define LANG_HOOKS_IDENTIFIER_SIZE	sizeof (struct lang_identifier)
+#define LANG_HOOKS_INIT_ONCE		lhd_do_nothing
 #define LANG_HOOKS_INIT			hook_bool_void_false
 #define LANG_HOOKS_FINISH		lhd_do_nothing
 #define LANG_HOOKS_PARSE_FILE		lhd_do_nothing_i
@@ -250,6 +251,7 @@ extern int lhd_tree_dump_type_quals (tre
   LANG_HOOKS_HANDLE_OPTION, \
   LANG_HOOKS_MISSING_ARGUMENT, \
   LANG_HOOKS_POST_OPTIONS, \
+  LANG_HOOKS_INIT_ONCE, \
   LANG_HOOKS_INIT, \
   LANG_HOOKS_FINISH, \
   LANG_HOOKS_PARSE_FILE, \
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.813.2.2
diff -u -p -r1.813.2.2 toplev.c
--- toplev.c	13 Aug 2003 21:59:57 -0000	1.813.2.2
+++ toplev.c	14 Aug 2003 20:22:15 -0000
@@ -108,6 +108,7 @@ static void general_init (const char *);
 static void do_compile (void);
 static void process_options (void);
 static void backend_init (void);
+static void init_compile_once (void);
 static int lang_dependent_init (const char *);
 static void init_asm_output (const char *);
 static void finalize (void);
@@ -4250,15 +4251,6 @@ process_options (void)
 static void
 backend_init (void)
 {
-  init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
-		  || debug_info_level == DINFO_LEVEL_VERBOSE
-#ifdef VMS_DEBUGGING_INFO
-		    /* Enable line number info for traceback.  */
-		    || debug_info_level > DINFO_LEVEL_NONE
-#endif
-		    || flag_test_coverage
-		    || warn_notreached);
-
   init_regs ();
   init_fake_stack_mems ();
   init_alias_once ();
@@ -4284,7 +4276,7 @@ lang_dependent_init (const char *name)
     dump_base_name = name ? name : "gccdump";
 
   /* Other front-end initialization.  */
-  if ((*lang_hooks.init) () == 0)
+  if ((*lang_hooks.init_eachsrc) () == 0)
     return 0;
 
   init_asm_output (name);
@@ -4375,6 +4367,25 @@ finalize (void)
   (*lang_hooks.finish) ();
 }
 
+/* Initialize the compiler.  */
+static void
+init_compile_once (void)
+{
+  /* The bulk of the command line switch processing.  */
+  process_options ();
+
+  init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
+		  || debug_info_level == DINFO_LEVEL_VERBOSE
+#ifdef VMS_DEBUGGING_INFO
+		    /* Enable line number info for traceback.  */
+		    || debug_info_level > DINFO_LEVEL_NONE
+#endif
+		    || flag_test_coverage
+		    || warn_notreached);
+
+  (*lang_hooks.init_once) ();
+}
+
 /* Initialize the compiler, and compile the input file.  */
 static void
 do_compile (void)
@@ -4385,8 +4396,6 @@ do_compile (void)
     timevar_init ();
   timevar_start (TV_TOTAL);
 
-  process_options ();
-
   /* Don't do any more if an error has already occurred.  */
   if (!errorcount)
     {
@@ -4444,7 +4453,13 @@ toplev_main (unsigned int argc, const ch
 
   /* Exit early if we can (e.g. -help).  */
   if (!exit_after_options)
-    do_compile ();
+    {
+      init_compile_once ();
+
+      /* If an error has already occurred, give up.  */
+      if (! errorcount)
+	do_compile ();
+    }
 
   if (errorcount || sorrycount)
     return (FATAL_EXIT_CODE);

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