diff mbox

[1/2] Introduce context class

Message ID 1374678544-8678-2-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm July 24, 2013, 3:09 p.m. UTC
gcc/

	Introduce context class.

	* Makefile.in (CONTEXT_H): New.
	(OBJS): Add context.o.
	(toplev.o): Add CONTEXT_H to dependencies.
	(context.o): New.

	* toplev.c (general_init): Create the singleton gcc::context
	instance.

	* context.c: New.

	* context.h: New.
---
 gcc/Makefile.in |  6 +++++-
 gcc/context.c   | 27 +++++++++++++++++++++++++++
 gcc/context.h   | 42 ++++++++++++++++++++++++++++++++++++++++++
 gcc/toplev.c    |  5 +++++
 4 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100644 gcc/context.c
 create mode 100644 gcc/context.h

Comments

Diego Novillo July 24, 2013, 10:55 p.m. UTC | #1
On Wed, Jul 24, 2013 at 11:09 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> gcc/
>
>         Introduce context class.
>
>         * Makefile.in (CONTEXT_H): New.
>         (OBJS): Add context.o.
>         (toplev.o): Add CONTEXT_H to dependencies.
>         (context.o): New.
>
>         * toplev.c (general_init): Create the singleton gcc::context
>         instance.
>
>         * context.c: New.
>
>         * context.h: New.

OK.


Diego.
David Malcolm July 25, 2013, 12:15 a.m. UTC | #2
On Wed, 2013-07-24 at 18:55 -0400, Diego Novillo wrote:
> On Wed, Jul 24, 2013 at 11:09 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> > gcc/
> >
> >         Introduce context class.
> >
> >         * Makefile.in (CONTEXT_H): New.
> >         (OBJS): Add context.o.
> >         (toplev.o): Add CONTEXT_H to dependencies.
> >         (context.o): New.
> >
> >         * toplev.c (general_init): Create the singleton gcc::context
> >         instance.
> >
> >         * context.c: New.
> >
> >         * context.h: New.
> 
> OK.

Thanks.

I doublechecked the bootstrap of *just* this patch (rather than the
combination of *both* patches) on x86_64-unknown-linux-gnu and it worked
OK, so I've committed this to svn trunk as r201230.
diff mbox

Patch

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 966c38a..fb0cb4b 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -986,6 +986,7 @@  PLUGIN_H = plugin.h $(GCC_PLUGIN_H)
 PLUGIN_VERSION_H = plugin-version.h configargs.h
 LIBFUNCS_H = libfuncs.h $(HASHTAB_H)
 GRAPHITE_HTAB_H = graphite-htab.h graphite-clast-to-gimple.h $(HASH_TABLE_H)
+CONTEXT_H = context.h
 
 #
 # Now figure out from those variables how to compile and link.
@@ -1200,6 +1201,7 @@  OBJS = \
 	combine.o \
 	combine-stack-adj.o \
 	compare-elim.o \
+	context.o \
 	convert.o \
 	coverage.o \
 	cppbuiltin.o \
@@ -2729,7 +2731,7 @@  toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
    $(OPTS_H) params.def tree-mudflap.h $(TREE_PASS_H) $(GIMPLE_H) \
    tree-ssa-alias.h $(PLUGIN_H) realmpfr.h tree-diagnostic.h \
    $(TREE_PRETTY_PRINT_H) opts-diagnostic.h $(COMMON_TARGET_H) \
-   tsan.h diagnostic-color.h
+   tsan.h diagnostic-color.h $(CONTEXT_H)
 
 hwint.o : hwint.c $(CONFIG_H) $(SYSTEM_H) $(DIAGNOSTIC_CORE_H)
 
@@ -3487,6 +3489,8 @@  $(out_object_file): $(out_file) $(CONFIG_H) coretypes.h $(TM_H) $(TREE_H) \
    regrename.h
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
 		$(out_file) $(OUTPUT_OPTION)
+context.o: context.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GGC_H) \
+   $(CONTEXT_H)
 
 $(common_out_object_file): $(common_out_file) $(CONFIG_H) $(SYSTEM_H) \
     coretypes.h $(COMMON_TARGET_H) $(COMMON_TARGET_DEF_H) $(PARAMS_H) \
diff --git a/gcc/context.c b/gcc/context.c
new file mode 100644
index 0000000..76e0dde
--- /dev/null
+++ b/gcc/context.c
@@ -0,0 +1,27 @@ 
+/* context.c - Holder for global state
+   Copyright (C) 2013 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "ggc.h"
+#include "context.h"
+
+/* The singleton holder of global state: */
+gcc::context *g;
diff --git a/gcc/context.h b/gcc/context.h
new file mode 100644
index 0000000..3caf02f
--- /dev/null
+++ b/gcc/context.h
@@ -0,0 +1,42 @@ 
+/* context.h - Holder for global state
+   Copyright (C) 2013 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_CONTEXT_H
+#define GCC_CONTEXT_H
+
+namespace gcc {
+
+/* GCC's internal state can be divided into zero or more
+   "parallel universe" of state; an instance of this class is one such
+   context of state.  */
+class context
+{
+public:
+
+  /* Currently empty.  */
+
+}; // class context
+
+} // namespace gcc
+
+/* The global singleton context aka "g".
+   (the name is chosen to be easy to type in a debugger).  */
+extern gcc::context *g;
+
+#endif /* ! GCC_CONTEXT_H */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index a2ee491..de28a2d 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -75,6 +75,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-alias.h"
 #include "plugin.h"
 #include "diagnostic-color.h"
+#include "context.h"
 
 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
 #include "dbxout.h"
@@ -1156,6 +1157,10 @@  general_init (const char *argv0)
   /* This must be done after global_init_params but before argument
      processing.  */
   init_ggc_heuristics();
+
+  /* Create the singleton holder for global state.  */
+  g = new gcc::context();
+
   init_optimization_passes ();
   statistics_early_init ();
   finish_params ();