Introduce context class.
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 25 Jul 2013 00:14:01 +0000 (00:14 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Thu, 25 Jul 2013 00:14:01 +0000 (00:14 +0000)
2013-07-24  David Malcolm  <dmalcolm@redhat.com>

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.

From-SVN: r201230

gcc/ChangeLog
gcc/Makefile.in
gcc/context.c [new file with mode: 0644]
gcc/context.h [new file with mode: 0644]
gcc/toplev.c

index 0277054..36bfbe9 100644 (file)
@@ -1,3 +1,19 @@
+2013-07-24  David Malcolm  <dmalcolm@redhat.com>
+
+       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.
+
 2013-07-24  Joern Rennecke  <joern.rennecke@embecosm.com>
 
        PR rtl-optimization/57968
index 966c38a..fb0cb4b 100644 (file)
@@ -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
 
 #\f
 # 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 (file)
index 0000000..76e0dde
--- /dev/null
@@ -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 (file)
index 0000000..3caf02f
--- /dev/null
@@ -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 */
index a2ee491..de28a2d 100644 (file)
@@ -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 ();