diff mbox

[pph] Add pph_writer_enabled_p (issue5003044)

Message ID 20110913190331.C6B5D1DA1A3@topo.tor.corp.google.com
State New
Headers show

Commit Message

Diego Novillo Sept. 13, 2011, 7:03 p.m. UTC
A small tweak to clarify what we mean when the code reads 'if (pph_out_file)'.
For the next patch I'm writing, I'm using this, so I'm flushing it first.

Tested on x86_64.  Applied.


Diego.

c-family/ChangeLog.pph

	* c-opts.c (pph_reader_enabled_p): Rename from query_have_pph_map.
	Update all users.

cp/ChangeLog.pph

	* Make-lang.in (cp/parser.o): Add dependency on CXX_PPH_STREAMER_H.
	* parser.c: Include pph-streamer.h
	* decl.c (cp_rest_of_decl_compilation): Call pph_writer_enabled_p.
	* pph-streamer-in.c (pph_read_file_1): Likewise.
	* semantics.c (expand_or_defer_fn_1): Likewise.
	* pph-streamer.h (pph_writer_enabled_p): New.
	(pph_enabled_p): Move from pph.h.
	* pph.c (pph_init): Call pph_writer_enabled_p.
	* pph.h: Move to pph-streamer.h.


--
This patch is available for review at http://codereview.appspot.com/5003044
diff mbox

Patch

diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 6f4dc1c..56dada4 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -584,10 +584,10 @@  extern const char *pch_file;
 
 extern const char *pph_out_file;
 
-/* Query if we have any map from INCLUDE to PPH file.  */
+/* Return true if we have any map from INCLUDE to PPH file.  */
 
 extern bool
-query_have_pph_map (void);
+pph_reader_enabled_p (void);
 
 /* Query for a mapping from an INCLUDE to a PPH file.
    Return the filename, without ownership.
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 3ee5860..6b63bda 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -129,13 +129,13 @@  static void c_finish_options (void);
 #endif
 
 /* Mappings from include directive to PPH file.  */
+static strstrmap_t *include_pph_mapping;
 
-strstrmap_t *include_pph_mapping;
 
-/* Query if we have any map from INCLUDE to PPH file.  */
+/* Return true if we have any map from INCLUDE to PPH file.  */
 
 bool
-query_have_pph_map (void)
+pph_reader_enabled_p (void)
 {
   return include_pph_mapping != NULL;
 }
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index a83d5a2..fe2b87e 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -342,7 +342,7 @@  cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) $(REAL_H) \
 cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) $(DIAGNOSTIC_CORE_H) \
   gt-cp-parser.h output.h $(TARGET_H) $(PLUGIN_H) intl.h \
   c-family/c-objc.h tree-pretty-print.h $(CXX_PARSER_H) $(TIMEVAR.H) \
-  $(CXX_PPH_H)
+  $(CXX_PPH_H) $(CXX_PPH_STREAMER_H)
 cp/cp-gimplify.o: cp/cp-gimplify.c $(CXX_TREE_H) $(C_COMMON_H) \
 	$(TM_H) coretypes.h pointer-set.h tree-iterator.h $(SPLAY_TREE_H)
 cp/name-lookup.o: cp/name-lookup.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e10eb88..cd3d0aa 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5906,7 +5906,7 @@  cp_rest_of_decl_compilation (tree decl, int top_level, int at_end)
   rest_of_decl_compilation (decl, top_level, at_end);
 
   /* If we are generating a PPH image, add DECL to its symbol table.  */
-  if (pph_out_file)
+  if (pph_writer_enabled_p ())
     pph_add_decl_to_symtab (decl, PPH_SYMTAB_DECLARE, top_level, at_end);
 }
 
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7253df6..3d476d6 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -26,6 +26,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "timevar.h"
 #include "cpplib.h"
 #include "pph.h"
+#include "pph-streamer.h"
 #include "tree.h"
 #include "cp-tree.h"
 #include "intl.h"
diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
index ea44460..f8238bf 100644
--- a/gcc/cp/pph-streamer-in.c
+++ b/gcc/cp/pph-streamer-in.c
@@ -1669,7 +1669,7 @@  pph_read_file_1 (pph_stream *stream)
   /* If we are generating an image, the PPH contents we just read from
      STREAM will need to be read again the next time we want to read
      the image we are now generating.  */
-  if (pph_out_file && !pph_reading_includes)
+  if (pph_writer_enabled_p () && !pph_reading_includes)
     pph_add_include (stream);
 }
 
diff --git a/gcc/cp/pph-streamer.h b/gcc/cp/pph-streamer.h
index 7f98764..ce2f379 100644
--- a/gcc/cp/pph-streamer.h
+++ b/gcc/cp/pph-streamer.h
@@ -281,6 +281,21 @@  extern void pph_in_spec_entry_tables (pph_stream *stream);
 
 /* Inline functions.  */
 
+/* Return true if we are generating a PPH image.  */
+static inline bool
+pph_writer_enabled_p (void)
+{
+  return pph_out_file != NULL;
+}
+
+/* Return true if PPH has been enabled.  */
+static inline bool
+pph_enabled_p (void)
+{
+  return pph_writer_enabled_p () || pph_reader_enabled_p ();
+}
+
+
 /* Output array A of cardinality C of ASTs to STREAM.  */
 /* FIXME pph: hold for alternate routine. */
 #if 0
diff --git a/gcc/cp/pph.c b/gcc/cp/pph.c
index cbd9c24..24744bb 100644
--- a/gcc/cp/pph.c
+++ b/gcc/cp/pph.c
@@ -186,7 +186,7 @@  pph_init (void)
   gcc_assert (table == NULL);
 
   /* If we are generating a PPH file, initialize the writer.  */
-  if (pph_out_file != NULL)
+  if (pph_writer_enabled_p ())
     pph_writer_init ();
 
   pph_init_preloaded_cache ();
diff --git a/gcc/cp/pph.h b/gcc/cp/pph.h
index 2197744..bc90f80 100644
--- a/gcc/cp/pph.h
+++ b/gcc/cp/pph.h
@@ -56,13 +56,6 @@  typedef struct cp_token_hunk *cp_token_hunk_ptr;
 DEF_VEC_P (cp_token_hunk_ptr);
 DEF_VEC_ALLOC_P (cp_token_hunk_ptr,gc);
 
-/* Return true if PPH has been enabled.  */
-static inline bool
-pph_enabled_p (void)
-{
-  return pph_out_file != NULL || query_have_pph_map ();
-}
-
 /* Global state.  FIXME pph, get rid of these.  */
 
 /* Log file where PPH analysis is written to.  Controlled by
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 868adb6..cd6ebac 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3571,7 +3571,7 @@  bool
 expand_or_defer_fn_1 (tree fn)
 {
   /* If we are generating a PPH image, add FN to its symbol table.  */
-  if (pph_out_file)
+  if (pph_writer_enabled_p ())
     pph_add_decl_to_symtab (fn, PPH_SYMTAB_EXPAND, false, at_eof);
 
   /* When the parser calls us after finishing the body of a template