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]

[tuples] GIMPLE_STATEMENT_LIST changes, redesign, and misc


Hi folks.

After talking with rth about the STATEMENT_LIST gc issues, he's suggested
experimenting with the idea of including the chain of gimple statements
inside the GIMPLE_STATEMENT_LIST node.  This will save us one indirection,
and eliminate gimple_statement_list_node, at the expense of adding two
link elements in ``struct gimple_stmt''.  Since we'll want to move
statements around, it makes sense to someone writing optimizers
to have to manipulate gimple_stmt nodes instead of copying the contents
into the list node.

We probably never have gimple_stmt's that aren't intended to be chained into
a list, so we don't waste memory with unused pointers.

In the case that gimple statements need to belong to more than one list
at a time, we can make a copy, but this probably doesn't happen (FLW).

This patch does a few things (besides the perfunctory comment and typo
fixing)...

- Add the notion of GIMPLE_STATEMENT_LIST.
- Add tags for TS_GIMPLE_STATEMENT_LIST and TS_GIMPLE_STATEMENT in tree_node.
- Add prev and next fields to `gimple_stmt'.

Next comes tree-iterator.* and STATEMENT_LIST overhaul.  Yay!

Richard, how does this look?

        * tree.c (tree_code_size): Handle GIMPLE_STATEMENT_LIST.
        (tree_node_structure): Handle GIMPLE_STATEMENT_LIST and
        GIMPLE_MODIFY_STMT.
        * tree.h (struct gimple_stmt): Add prev and next fields.
        (GIMPLE_STMT_TO_TREE): Cast, do not call GIMPLE_STMT_CHECK.
        (GIMPLE_STATEMENT_LIST_HEAD): New.
        (GIMPLE_STATEMENT_LIST_TAIL): New.
        (struct gimple_statement_list): New.
        (union tree_node): Add gimple_stmt_list and gstmt.
        * treestruct.def: Add TS_GIMPLE_STATEMENT_LIST, TS_GIMPLE_STATEMENT.
        * tree.def: Add GIMPLE_STATEMENT_LIST.

Index: tree.c
===================================================================
--- tree.c	(revision 116725)
+++ tree.c	(working copy)
@@ -390,6 +390,8 @@ tree_code_size (enum tree_code code)
 	case SSA_NAME:		return sizeof (struct tree_ssa_name);
 
 	case STATEMENT_LIST:	return sizeof (struct tree_statement_list);
+	case GIMPLE_STATEMENT_LIST:
+	  return sizeof (struct gimple_statement_list);
 	case BLOCK:		return sizeof (struct tree_block);
 	case VALUE_HANDLE:	return sizeof (struct tree_value_handle);
 	case CONSTRUCTOR:	return sizeof (struct tree_constructor);
@@ -2183,6 +2185,8 @@ tree_node_structure (tree t)
     case SSA_NAME:		return TS_SSA_NAME;
     case PLACEHOLDER_EXPR:	return TS_COMMON;
     case STATEMENT_LIST:	return TS_STATEMENT_LIST;
+    case GIMPLE_STATEMENT_LIST:	return TS_GIMPLE_STATEMENT_LIST;
+    case GIMPLE_MODIFY_STMT:	return TS_GIMPLE_STATEMENT;
     case BLOCK:			return TS_BLOCK;
     case CONSTRUCTOR:		return TS_CONSTRUCTOR;
     case TREE_BINFO:		return TS_BINFO;
Index: tree.h
===================================================================
--- tree.h	(revision 116725)
+++ tree.h	(working copy)
@@ -401,6 +401,8 @@ struct gimple_stmt GTY(())
   struct tree_base base;
   source_locus locus;
   tree block;
+  struct gimple_stmt *prev;
+  struct gimple_stmt *next;
   struct tree_base *operands[1];
 };
 
@@ -904,11 +906,11 @@ extern void omp_clause_range_check_faile
 /* Nonzero if NODE is a GIMPLE tuple.  */
 #define GIMPLE_TUPLE_P(NODE) (GIMPLE_STMT_P (NODE))
 
-/* Convert a GIMPLE_STMT into a TREE.  */
+/* Convert a TREE into a GIMPLE_STMT.  */
 #define TREE_TO_GIMPLE_STMT(T) ((struct gimple_stmt *)(GIMPLE_STMT_CHECK (T)))
 
-/* Convert a TREE into a GIMPLE_STMT.  */
-#define GIMPLE_STMT_TO_TREE(T) (GIMPLE_STMT_CHECK ((tree)(T)))
+/* Convert a GIMPLE_STMT into a TREE.  */
+#define GIMPLE_STMT_TO_TREE(T) ((tree)(T))
 
 /* Given a TREE, return its operand number I.  */
 #define GIMPLE_STMT_OPERAND(T, I) \
@@ -3157,7 +3159,7 @@ struct tree_type_decl GTY(())
 
 };
 
-/* A STATEMENT_LIST chains statements together in GENERIC and GIMPLE.
+/* A STATEMENT_LIST chains statements together in GENERIC.
    To reduce overhead, the nodes containing the statements are not trees.
    This avoids the overhead of tree_common on all linked list elements.
 
@@ -3184,6 +3186,22 @@ struct tree_statement_list
   struct tree_statement_list_node *tail;
 };
 
+/* A GIMPLE_STATEMENT_LIST is similar to STATEMENT_LIST but for GIMPLE
+   statements.  */
+
+#define GIMPLE_STATEMENT_LIST_HEAD(NODE) \
+  (GIMPLE_STATEMENT_LIST_CHECK (NODE)->gimple_stmt_list.head)
+#define GIMPLE_STATEMENT_LIST_TAIL(NODE) \
+  (GIMPLE_STATEMENT_LIST_CHECK (NODE)->gimple_stmt_list.tail)
+
+struct gimple_statement_list
+  GTY(())
+{
+  struct tree_common common;
+  struct gimple_stmt *head;
+  struct gimple_stmt *tail;
+};
+
 #define VALUE_HANDLE_ID(NODE)		\
   (VALUE_HANDLE_CHECK (NODE)->value_handle.id)
 
@@ -3248,6 +3266,8 @@ union tree_node GTY ((ptr_alias (union l
   struct tree_block GTY ((tag ("TS_BLOCK"))) block;
   struct tree_binfo GTY ((tag ("TS_BINFO"))) binfo;
   struct tree_statement_list GTY ((tag ("TS_STATEMENT_LIST"))) stmt_list;
+  struct gimple_statement_list GTY ((tag ("TS_GIMPLE_STATEMENT_LIST"))) gimple_stmt_list;
+  struct gimple_stmt * GTY ((tag ("TS_GIMPLE_STATEMENT"))) gstmt;
   struct tree_value_handle GTY ((tag ("TS_VALUE_HANDLE"))) value_handle;
   struct tree_constructor GTY ((tag ("TS_CONSTRUCTOR"))) constructor;
   struct tree_memory_tag GTY ((tag ("TS_MEMORY_TAG"))) mtag;
Index: treestruct.def
===================================================================
--- treestruct.def	(revision 116647)
+++ treestruct.def	(working copy)
@@ -57,6 +57,8 @@ DEFTREESTRUCT(TS_PHI_NODE, "phi node")
 DEFTREESTRUCT(TS_BLOCK, "block")
 DEFTREESTRUCT(TS_BINFO, "binfo")
 DEFTREESTRUCT(TS_STATEMENT_LIST, "statement list")
+DEFTREESTRUCT(TS_GIMPLE_STATEMENT_LIST, "gimple statement list")
+DEFTREESTRUCT(TS_GIMPLE_STATEMENT, "gimple statement")
 DEFTREESTRUCT(TS_VALUE_HANDLE, "value handle")
 DEFTREESTRUCT(TS_CONSTRUCTOR, "constructor")
 DEFTREESTRUCT(TS_MEMORY_TAG, "memory tag")
Index: tree.def
===================================================================
--- tree.def	(revision 116725)
+++ tree.def	(working copy)
@@ -896,6 +896,9 @@ DEFTREECODE (POLYNOMIAL_CHREC, "polynomi
    Use the interface in tree-iterator.h to access this node.  */
 DEFTREECODE (STATEMENT_LIST, "statement_list", tcc_exceptional, 0)
 
+/* Similarly for gimple statements.  */
+DEFTREECODE (GIMPLE_STATEMENT_LIST, "gimple_statement_list", tcc_exceptional, 0)
+
 /* Value handles.  Artificial nodes to represent expressions in
    partial redundancy elimination (tree-ssa-pre.c).  These nodes are
    used for expression canonicalization.  If two expressions compute


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