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]

[lno] Some functions for the loop structure


Bootstrapped on i686-pc-linux-gnu.

	* cfgloop.h (loop_is_included_in, outer_loop, inner_loop,
	next_loop, loop_num, loop_depth, loop_header,
	loop_nb_iterations, loop_num_exits, loop_exit_edges,
	loop_exit_edge): New inline functions.
	(loop_is_included_in): Declare here.
	* tree-flow-inline.h (loop_of_stmt): New inline function.
	* tree-scalar-evolution.h (loop_is_included_in): Remove declaration.
	(stmt_is_in_loop, stmt_is_not_in_loop): New functions.
	(loop_is_included_in, loop_is_included_in_rec): Moved up in the same file.

Index: cfgloop.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloop.h,v
retrieving revision 1.2.4.9.2.2
diff -d -u -p -r1.2.4.9.2.2 cfgloop.h
--- cfgloop.h	3 Jan 2004 20:25:25 -0000	1.2.4.9.2.2
+++ cfgloop.h	6 Jan 2004 18:45:49 -0000
@@ -345,8 +345,18 @@ enum
 
 extern void unroll_and_peel_loops (struct loops *, int);
 
-
+extern bool loop_is_included_in (unsigned, unsigned);
 static inline struct loop *loop_from_num (struct loops *, unsigned);
+static inline struct loop *outer_loop (struct loop *);
+static inline struct loop *inner_loop (struct loop *);
+static inline struct loop *next_loop (struct loop *);
+static inline unsigned loop_num (struct loop *);
+static inline unsigned loop_depth (struct loop *);
+static inline basic_block loop_header (struct loop *);
+static inline tree loop_nb_iterations (struct loop *);
+static inline unsigned loop_num_exits (struct loop *);
+static inline edge *loop_exit_edges (struct loop *);
+static inline edge loop_exit_edge (struct loop *, unsigned);
 
 static inline struct loop *
 loop_from_num (struct loops *loops, 
@@ -355,6 +365,88 @@ loop_from_num (struct loops *loops, 
   return loops->parray[num];
 }
 
+/* Returns the outer loop.  */
+
+static inline struct loop *
+outer_loop (struct loop *loop)
+{
+  return loop->outer;
+}
+
+/* Returns the inner loop.  */
+
+static inline struct loop *
+inner_loop (struct loop *loop)
+{
+  return loop->inner;
+}
+
+/* Returns the next loop.  */
+
+static inline struct loop *
+next_loop (struct loop *loop)
+{
+  return loop->next;
+}
+
+/* Returns the number of a loop.  */
+
+static inline unsigned
+loop_num (struct loop *loop)
+{
+  return loop->num;
+}
+
+/* Returns the depth of a loop.  */
+
+static inline unsigned
+loop_depth (struct loop *loop)
+{
+  return loop->depth;
+}
+
+/* Returns the header basic block of the loop.  */
+
+static inline basic_block
+loop_header (struct loop *loop)
+{
+  return loop->header;
+}
+
+/* Returns the number of iterations in the loop.  */
+
+static inline tree
+loop_nb_iterations (struct loop *loop)
+{
+  return loop->nb_iterations;
+}
+
+/* Returns the number of exit edges of the loop.  */
+
+static inline unsigned
+loop_num_exits (struct loop *loop)
+{
+  return loop->num_exits;
+}
+
+/* Returns the exit edges of the loop.  */
+
+static inline edge *
+loop_exit_edges (struct loop *loop)
+{
+  return loop->exit_edges;
+}
+
+/* Returns the n-th exit edge of the loop.  */
+
+static inline edge 
+loop_exit_edge (struct loop *loop, unsigned n)
+{
+  return loop->exit_edges[n];
+}
+
+
 /* Loop optimizer dump file.  */
 extern FILE *loop_dump_file;
 extern int loop_dump_flags;
+
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v
retrieving revision 1.1.2.64
diff -d -u -p -r1.1.2.64 tree-flow-inline.h
--- tree-flow-inline.h	19 Dec 2003 01:01:49 -0000	1.1.2.64
+++ tree-flow-inline.h	6 Jan 2004 18:45:49 -0000
@@ -563,4 +563,12 @@ bsi_stmt_ptr (block_stmt_iterator i)
   return tsi_stmt_ptr (i.tsi);
 }
 
+/* Returns the loop of the statement STMT.  */
+
+static inline struct loop *
+loop_of_stmt (tree stmt)
+{
+  return bb_for_stmt (stmt)->loop_father;
+}
+
 #endif /* _TREE_FLOW_INLINE_H  */
Index: tree-scalar-evolution.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-scalar-evolution.c,v
retrieving revision 1.1.2.3
diff -d -u -p -r1.1.2.3 tree-scalar-evolution.c
--- tree-scalar-evolution.c	2 Jan 2004 23:28:32 -0000	1.1.2.3
+++ tree-scalar-evolution.c	6 Jan 2004 18:45:49 -0000
@@ -179,8 +179,6 @@ static void set_scev                   (
 static void set_scev_inner_value       (unsigned, tree, tree);
 static void set_scev_outer_value       (tree, tree);
 static tree get_scev                   (unsigned, tree);
-static bool loop_is_included_in        (unsigned, unsigned);
-static bool loop_is_included_in_rec    (unsigned, struct loop *);
 static tree merge_evolutions           (tree, varray_type);
 static void merge_branches_of_condition_phi_node_in_loop (tree, tree);
 static void merge_branches_of_condition_phi_node (tree);
@@ -286,6 +284,83 @@ static int dump_flags;
 
 
 
+/* Loop related functions.  */
+
+static bool loop_is_included_in_rec (unsigned, struct loop *);
+static inline bool stmt_is_in_loop (tree, unsigned);
+
+/* Determines whether STMT is in loop LOOP_NB.  */
+
+static inline bool
+stmt_is_in_loop (tree stmt, 
+		 unsigned loop_nb)
+{
+  if (loop_is_included_in (loop_num (loop_of_stmt (stmt)), loop_nb))
+    return true;
+  
+  else
+    return false;
+}
+
+/* Determines whether STMT is not contained by the loop LOOP_NB.  */
+
+static inline bool
+stmt_is_not_in_loop (tree stmt, 
+		     unsigned loop_nb)
+{
+  return !stmt_is_in_loop (stmt, loop_nb);
+}
+
+/* Determines whether loop A is contained in loop B.  
+   
+   FIXME: Maybe it would be better to record this information as a bit
+   matrix in the loops structure.  */
+
+bool
+loop_is_included_in (unsigned a, 
+		     unsigned b)
+{
+  struct loop *loop_b;
+  
+  if (a == b)
+    return true;
+  
+  /* That's a property of the loops->parray (see the comment in the
+     loops structure).  */
+  if (a < b)
+    return false;
+  
+  loop_b = loop_from_num (monev_loops, b);
+  
+  if (inner_loop (loop_b)
+      && loop_is_included_in_rec (a, inner_loop (loop_b)))
+    return true;
+  
+  return false;
+}
+
+/* Recursively determine whether A is contained in LOOP_B.  */
+
+static bool
+loop_is_included_in_rec (unsigned a, 
+			 struct loop *loop_b)
+{
+  if (loop_num (loop_b) == a)
+    return true;
+  
+  if (inner_loop (loop_b)
+      && loop_is_included_in_rec (a, inner_loop (loop_b)))
+    return true;
+  
+  if (next_loop (loop_b)
+      && loop_is_included_in_rec (a, next_loop (loop_b)))
+    return true;
+  
+  return false;
+}
+
+
+
 /* Imperative list functions.  */
 
 static inline tree ssa_name_at_index_in_imperative_list (int, varray_type);
@@ -1749,52 +1824,6 @@ get_scev (unsigned loop_num, tree var)
 
 	 fprintf (stderr, ")\n"));
   return res;
-}
-
-/* Determines whether loop A is contained in loop B.  
-   
-   FIXME: Maybe it would be better to record this information as a bit
-   matrix in the loops structure.  */
-
-static bool
-loop_is_included_in (unsigned a, unsigned b)
-{
-  struct loop *loop_b;
-  
-  if (a == b)
-    return true;
-  
-  /* That's a property of the loops->parray (see the comment in the
-     loops structure).  */
-  if (a < b)
-    return false;
-  
-  loop_b = loop_from_num (monev_loops, b);
-  
-  if (loop_b->inner
-      && loop_is_included_in_rec (a, loop_b->inner))
-    return true;
-  
-  return false;
-}
-
-/* Recursively determine whether A is contained in LOOP_B.  */
-
-static bool
-loop_is_included_in_rec (unsigned a, struct loop *loop_b)
-{
-  if (loop_b->num == (int) a)
-    return true;
-  
-  if (loop_b->inner
-      && loop_is_included_in_rec (a, loop_b->inner))
-    return true;
-  
-  if (loop_b->next
-      && loop_is_included_in_rec (a, loop_b->next))
-    return true;
-  
-  return false;
 }
 
 /* Merge the evolution functions from BRANCH_CHRECS with the


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