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][PATCH] API to access ddg info


This patch adds two routines to access data dependence info from DDG.
Bootstrapped on powerpc-darwin. Next patch will add use of it in
auto vectorizer.

--
Devang

2004-02-20 Devang Patel <dpatel@apple.com>

* tree-data-ref.h (data_dependence_direction): Add new member dir_independent.
* tree-dg.h (tree-data-ref.h): Include.
(ddg_direction_between_stmts, ddg_distance_between_stmts): New decls.
* tree-dg.c (find_ddr_between_stmts, ddg_direction_between_stmts,
ddg_distance_between_stmts): New functions.



Index: tree-data-ref.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/Attic/tree-data-ref.h,v retrieving revision 1.1.2.5 diff -Idpatel.pbxuser -c -3 -p -r1.1.2.5 tree-data-ref.h *** tree-data-ref.h 16 Feb 2004 21:59:28 -0000 1.1.2.5 --- tree-data-ref.h 20 Feb 2004 19:58:46 -0000 *************** enum data_dependence_direction { *** 55,61 **** dir_positive_or_negative, dir_positive_or_equal, dir_negative_or_equal, ! dir_star };

  /* What is a subscript?  Given two array accesses a subscript is the
--- 55,62 ----
    dir_positive_or_negative,
    dir_positive_or_equal,
    dir_negative_or_equal,
!   dir_star,
!   dir_independent
  };

  /* What is a subscript?  Given two array accesses a subscript is the
Index: tree-dg.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dg.h,v
retrieving revision 1.1.2.2
diff -Idpatel.pbxuser -c -3 -p -r1.1.2.2 tree-dg.h
*** tree-dg.h   20 Feb 2004 01:32:36 -0000      1.1.2.2
--- tree-dg.h   20 Feb 2004 19:58:46 -0000
*************** Software Foundation, 59 Temple Place - S
*** 22,27 ****
--- 22,29 ----
  #ifndef GCC_TREE_SSA_DG_H
  #define GCC_TREE_SSA_DG_H

+ #include "tree-data-ref.h"
+
  struct dependence_edge_def GTY (())
  {
    /* Dependence relation */
*************** void dg_delete_edge (dependence_edge);
*** 75,78 ****
--- 77,87 ----

/* Debug dependence graph. */
extern void debug_dg (int);
+
+ /* Find data dependence direction between two statements. */
+ enum ddg_dependence_direction data_direction_between_stmts (tree, tree, int);
+
+ /* Find data dependence distance between two statements. */
+ tree ddg_distance_between_stmts (tree, tree, int);
+
#endif
Index: tree-dg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dg.c,v
retrieving revision 1.1.2.2
diff -Idpatel.pbxuser -c -3 -p -r1.1.2.2 tree-dg.c
*** tree-dg.c 20 Feb 2004 01:32:36 -0000 1.1.2.2
--- tree-dg.c 20 Feb 2004 19:58:47 -0000
*************** static bool gate_ddg (void);
*** 64,69 ****
--- 64,70 ----
static void dump_dg (FILE *, int);
static void dg_delete_edges (void);
static void dg_delete_node (dependence_node);
+ static struct data_dependence_relation * find_ddr_between_stmts (tree, tree);


  /* Initial dependence graph capacity.  */
  static int dependence_graph_size = 25;
*************** set_dg_node_for_stmt (tree t, dependence
*** 424,429 ****
--- 425,512 ----

ann->dg_node = dg_node;
}
+
+ / *----------------------------------------------------------------------- ----
+ Dependence Info Access
+ ------------------------------------------------------------------------ ---*/
+
+ /* Find data dependence relation between two statements. If there is no
+ relation between two statements then return NULL. */
+
+ static struct data_dependence_relation *
+ find_ddr_between_stmts (tree stmt1, tree stmt2)
+ {
+ dependence_edge e = NULL;
+ dependence_node n1 = NULL;
+ dependence_node n2 = NULL;
+
+
+ #ifdef ENABLE_CHECKING
+ if (!stmt1 || !stmt2)
+ abort ();
+ #endif
+
+ /* First find nodes for the statements. */
+ n1 = dg_node_for_stmt (stmt1);
+ n2 = dg_node_for_stmt (stmt2);
+
+ /* If associated dependence node does not exist then this
+ two statements are independent. */
+ if (!n1 || !n2)
+ return NULL;
+
+ /* Find edge between these two statements. */
+ e = dg_find_edge (n1, n2, false /* Do not create new edge */);
+
+ /* Absence of edge indicates that this two statements are independent. */
+ if (!e)
+ return NULL;
+
+ return e->ddr;
+
+ }
+
+ /* Find data dependence direction between two statements. */
+
+ enum data_dependence_direction
+ ddg_direction_between_stmts (tree stmt1, tree stmt2, int loop_num)
+ {
+ struct subscript *sub = NULL;
+ struct data_dependence_relation *ddr = find_ddr_between_stmts (stmt1, stmt2);
+
+ /* If there is no relation then statements are independent. */
+ if (!ddr)
+ return dir_independent;
+
+ /* Get subscript info. */
+ sub = DDR_SUBSCRIPT (ddr, loop_num);
+ if (!sub)
+ abort ();
+
+ return SUB_DIRECTION (sub);
+ }
+
+ /* Find data dependence distance between two statements. */
+
+ tree
+ ddg_distance_between_stmts (tree stmt1, tree stmt2, int loop_num)
+ {
+ struct subscript *sub = NULL;
+ struct data_dependence_relation *ddr = find_ddr_between_stmts (stmt1, stmt2);
+
+ /* If there is no relation then statements are independent. */
+ if (!ddr)
+ return NULL_TREE;
+
+ /* Get subscript info. */
+ sub = DDR_SUBSCRIPT (ddr, loop_num);
+ if (!sub)
+ abort ();
+
+ return SUB_DISTANCE (sub);
+ }
+
+


/ *----------------------------------------------------------------------- ----
Pass management



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