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]

[tree-ssa-branch] Minor fixes [patch]


Just rearranges some code and adds consistency checks here and
there.  Bootstrapped and tested on x86.


Diego.

	* Makefile.in (tree-ssa.o): Add dependency on c-tree.h
	* c-simplify.c (mark_not_simple_r): Don't mark IDENTIFIER_NODEs.
	* tree-dfa.c (function_may_recurse_p): Fix comment.
	(dump_ref): Don't dump immediate uses for PHI nodes more than once.
	(dump_referenced_vars): Unparse the name of the variable.
	* tree-flow.h (dump_tree_ssa): Declare.
	(debug_tree_ssa): Declare.
	(replace_ref_operand_with): Check if OPERAND_P is NULL.
	(restore_ref_operand): Ditto.
	(tree_annotation): Check that constants, types and IDENTIFIER_NODEs
	are not being annotated.
	* tree-ssa.c: Include c-tree.h.
	(dump_reaching_defs): Unparse the variable name.
	(dump_tree_ssa): New function.
	(tree_build_ssa): Call it.
	(debug_tree_ssa): New function.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.903.2.28
diff -d -u -p -r1.903.2.28 Makefile.in
--- Makefile.in	15 Sep 2002 18:50:30 -0000	1.903.2.28
+++ Makefile.in	17 Sep 2002 19:41:27 -0000
@@ -1381,7 +1381,8 @@ tree-alias-common.o: tree-alias-common.c
 	$(C_COMMON_H)
 tree-ssa.o : tree-ssa.c tree-optimize.h tree-flow.h $(CONFIG_H) $(SYSTEM_H) \
    $(RTL_H) $(TREE_H) $(TM_P_H) $(BASIC_BLOCK_H) $(EXPR_H) $(C_COMMON_H) \
-   $(GGC_H) output.h diagnostic.h ssa.h errors.h toplev.h ggc.h tree-simple.h
+   $(GGC_H) output.h diagnostic.h ssa.h errors.h toplev.h ggc.h tree-simple.h \
+   $(C_TREE_H)
 tree-ssa-pre.o : tree-ssa-pre.c tree-optimize.h tree-flow.h $(CONFIG_H) \
    $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(BASIC_BLOCK_H) $(EXPR_H) \
    $(C_COMMON_H) $(GGC_H) output.h diagnostic.h ssa.h errors.h toplev.h
Index: c-simplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/c-simplify.c,v
retrieving revision 1.1.4.23
diff -d -u -p -r1.1.4.23 c-simplify.c
--- c-simplify.c	9 Sep 2002 11:30:09 -0000	1.1.4.23
+++ c-simplify.c	17 Sep 2002 19:41:27 -0000
@@ -2814,19 +2814,14 @@ mark_not_simple_r (tp, walk_subtrees, da
      int *walk_subtrees;
      void *data ATTRIBUTE_UNUSED;
 {
-  switch (TREE_CODE_CLASS (TREE_CODE (*tp)))
-    {
-      case 'c':
-      case 'd':
-      case 't':
-	/* Don't mark constants, declarations nor types.  */
-	*walk_subtrees = 0;
-	break;
+  const enum tree_code code = TREE_CODE (*tp);
+  const char class = TREE_CODE_CLASS (code);
 
-      default:
-	set_tree_flag (*tp, TF_NOT_SIMPLE);
-	break;
-    }
+  /* Don't mark constants, identifier nodes, declarations nor types.  */
+  if (class == 'c' || class == 'd' || class == 't' || code == IDENTIFIER_NODE)
+    *walk_subtrees = 0;
+  else
+    set_tree_flag (*tp, TF_NOT_SIMPLE);
 
   return NULL_TREE;
 }
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.16
diff -d -u -p -r1.1.4.16 tree-dfa.c
--- tree-dfa.c	13 Sep 2002 17:46:52 -0000	1.1.4.16
+++ tree-dfa.c	17 Sep 2002 19:41:30 -0000
@@ -873,8 +873,8 @@ remove_tree_ann (t)
 
 /* Return 1 if the function may call itself.
    
-   ??? Currently this is very limited because we do not have call-graph
-       information.  */
+   FIXME Currently this is very limited because we do not have call-graph
+	 information.  */
 
 int
 function_may_recurse_p ()
@@ -1092,7 +1092,7 @@ dump_ref (outf, prefix, ref, indent, det
 	  dump_ref_array (outf, prefix, EXPRPHI_PHI_ARGS (ref), indent + 4, 1);
 	}	
 
-      if ((ref_type (ref) & (V_DEF | V_PHI)) && imm_uses (ref))
+      if ((ref_type (ref) & V_DEF) && imm_uses (ref))
 	{
 	  fputs (" immediate uses:\n", outf);
 	  dump_ref_list (outf, prefix, imm_uses (ref), indent + 4, 0);
@@ -1218,7 +1218,9 @@ dump_referenced_vars (file)
     {
       tree var = referenced_var (i);
       print_node_brief (file, "", var, 0);
-      fputc ('\n', file);
+      fprintf (file, " (");
+      print_c_node (file, var);
+      fprintf (file, " )\n");
       dump_ref_list (file, "", tree_refs (var), 4, 1);
       fputc ('\n', file);
     }
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.13
diff -d -u -p -r1.1.4.13 tree-flow.h
--- tree-flow.h	12 Sep 2002 11:03:15 -0000	1.1.4.13
+++ tree-flow.h	17 Sep 2002 19:41:30 -0000
@@ tree-flow.h			PARAMS ((void))
 extern void tree_ssa_remove_phi_alternative PARAMS ((tree_ref, basic_block));
 extern void dump_reaching_defs		PARAMS ((FILE *));
 extern void debug_reaching_defs		PARAMS ((void));
+extern void dump_tree_ssa		PARAMS ((FILE *));
+extern void debug_tree_ssa		PARAMS ((void));
 
 /* Functions in tree-alias-steen.c  */
 extern void create_alias_vars		PARAMS ((void));
@@ -858,7 +860,8 @@ replace_ref_operand_with (ref, op)
      tree_ref ref;
      tree op;
 {
-  *(ref->common.operand_p) = op;
+  if (ref->common.operand_p)
+    *(ref->common.operand_p) = op;
 }
 
 /* Restores the operand for REF with its original value (i.e., with the
@@ -867,7 +870,8 @@ static inline void
 restore_ref_operand (ref)
      tree_ref ref;
 {
-  *(ref->common.operand_p) = ref->common.orig_operand;
+  if (ref->common.operand_p)
+    *(ref->common.operand_p) = ref->common.orig_operand;
 }
 
 /* Return the annotation attached to T.  Create a new one if necessary.  */
@@ -875,6 +879,12 @@ static inline tree_ann
 tree_annotation (t)
      tree t;
 {
+#if defined ENABLE_CHECKING
+  if (TREE_CODE_CLASS (TREE_CODE (t)) == 'c'
+      || TREE_CODE_CLASS (TREE_CODE (t)) == 't'
+      || TREE_CODE (t) == IDENTIFIER_NODE)
+    abort ();
+#endif
   return ((t->common.aux) ? (tree_ann)t->common.aux : create_tree_ann (t));
 }
 
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.16
diff -d -u -p -r1.1.4.16 tree-ssa.c
--- tree-ssa.c	13 Sep 2002 17:46:52 -0000	1.1.4.16
+++ tree-ssa.c	17 Sep 2002 19:41:30 -0000
@@ -36,6 +36,7 @@ Boston, MA 02111-1307, USA.  */
 /* This should be eventually be generalized to other languages, but
    this would require a shared function-as-trees infrastructure.  */
 #include "c-common.h"
+#include "c-tree.h"
 #include "bitmap.h"
 
 #include "tree-optimize.h"
@@ -103,21 +104,7 @@ tree_build_ssa ()
 
   if (dump_file)
     {
-      basic_block bb;
-
-      fputc ('\n', dump_file);
-      fprintf (dump_file, ";; Function %s\n\n",
-	       IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
-
-      fputs ("SSA information\n\n", dump_file);
-
-      FOR_EACH_BB (bb)
-	{
-	  tree_dump_bb (dump_file, "", bb, 0);
-	  dump_ref_list (dump_file, "    ", bb_refs (bb), 0, 1);
-	  fputs ("\n\n", dump_file);
-	}
-
+      dump_tree_ssa (dump_file);
       dump_end (TDI_ssa, dump_file);
     }
 }
@@ -665,7 +652,9 @@ tree_ssa_remove_phi_alternative (phi_nod
     }
 }
 
+
 /* Dump reaching definitions for all the definitions in the function.  */
+
 void
 dump_reaching_defs (dump_file)
      FILE *dump_file;
@@ -684,7 +673,7 @@ dump_reaching_defs (dump_file)
       tree_ref u;
 
       fprintf (dump_file, "Variable: ");
-      print_node_brief (dump_file, "", var, 0);
+      print_c_node (dump_file, var);
       fprintf (dump_file, "\n");
 
       FOR_EACH_REF (u, tmp, tree_refs (var))
@@ -707,4 +696,36 @@ void
 debug_reaching_defs ()
 {
   dump_reaching_defs (stderr);
+}
+
+
+/* Dump SSA information to DUMP_FILE.  */
+
+void
+dump_tree_ssa (dump_file)
+     FILE *dump_file;
+{
+  basic_block bb;
+
+  fputc ('\n', dump_file);
+  fprintf (dump_file, ";; Function %s\n\n",
+      IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
+
+  fputs ("SSA information\n\n", dump_file);
+
+  FOR_EACH_BB (bb)
+    {
+      tree_dump_bb (dump_file, "", bb, 0);
+      dump_ref_list (dump_file, "    ", bb_refs (bb), 0, 1);
+      fputs ("\n\n", dump_file);
+    }
+}
+
+
+/* Dump SSA information to stderr.  */
+
+void
+debug_tree_ssa ()
+{
+  dump_tree_ssa (stderr);
 }


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