diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 02770542687..36bfbe976db 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2013-07-24 David Malcolm + + 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 PR rtl-optimization/57968 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 966c38a061d..fb0cb4b7028 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 00000000000..76e0dde9c0f --- /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 +. */ + +#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 00000000000..3caf02fed31 --- /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 +. */ + +#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 a2ee4913090..de28a2d4df1 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 ();