00001 /* DDG - Data Dependence Graph - interface. 00002 Copyright (C) 2004 00003 Free Software Foundation, Inc. 00004 Contributed by Ayal Zaks and Mustafa Hagog <zaks,mustafa@il.ibm.com> 00005 00006 This file is part of GCC. 00007 00008 GCC is free software; you can redistribute it and/or modify it under 00009 the terms of the GNU General Public License as published by the Free 00010 Software Foundation; either version 2, or (at your option) any later 00011 version. 00012 00013 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 00014 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00015 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00016 for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with GCC; see the file COPYING. If not, write to the Free 00020 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 00021 02111-1307, USA. */ 00022 00023 #ifndef GCC_DDG_H 00024 #define GCC_DDG_H 00025 00026 /* For sbitmap. */ 00027 #include "sbitmap.h" 00028 /* For basic_block. */ 00029 #include "basic-block.h" 00030 /* For struct df. */ 00031 #include "df.h" 00032 00033 typedef struct ddg_node *ddg_node_ptr; 00034 typedef struct ddg_edge *ddg_edge_ptr; 00035 typedef struct ddg *ddg_ptr; 00036 typedef struct ddg_scc *ddg_scc_ptr; 00037 typedef struct ddg_all_sccs *ddg_all_sccs_ptr; 00038 00039 typedef enum {TRUE_DEP, OUTPUT_DEP, ANTI_DEP} dep_type; 00040 typedef enum {REG_OR_MEM_DEP, REG_DEP, MEM_DEP, REG_AND_MEM_DEP} 00041 dep_data_type; 00042 00043 /* The following two macros enables direct access to the successors and 00044 predecessors bitmaps held in each ddg_node. Do not make changes to 00045 these bitmaps, unless you want to change the DDG. */ 00046 #define NODE_SUCCESSORS(x) ((x)->successors) 00047 #define NODE_PREDECESSORS(x) ((x)->predecessors) 00048 00049 /* A structure that represents a node in the DDG. */ 00050 struct ddg_node 00051 { 00052 /* Each node has a unique CUID index. These indices increase monotonically 00053 (according to the order of the corresponding INSN in the BB), starting 00054 from 0 with no gaps. */ 00055 int cuid; 00056 00057 /* The insn represented by the node. */ 00058 rtx insn; 00059 00060 /* A note preceding INSN (or INSN itself), such that all insns linked 00061 from FIRST_NOTE until INSN (inclusive of both) are moved together 00062 when reordering the insns. This takes care of notes that should 00063 continue to precede INSN. */ 00064 rtx first_note; 00065 00066 /* Incoming and outgoing dependency edges. */ 00067 ddg_edge_ptr in; 00068 ddg_edge_ptr out; 00069 00070 /* Each bit corresponds to a ddg_node according to its cuid, and is 00071 set iff the node is a successor/predecessor of "this" node. */ 00072 sbitmap successors; 00073 sbitmap predecessors; 00074 00075 /* For general use by algorithms manipulating the ddg. */ 00076 union { 00077 int count; 00078 void *info; 00079 } aux; 00080 }; 00081 00082 /* A structure that represents an edge in the DDG. */ 00083 struct ddg_edge 00084 { 00085 /* The source and destination nodes of the dependency edge. */ 00086 ddg_node_ptr src; 00087 ddg_node_ptr dest; 00088 00089 /* TRUE, OUTPUT or ANTI dependency. */ 00090 dep_type type; 00091 00092 /* REG or MEM dependency. */ 00093 dep_data_type data_type; 00094 00095 /* Latency of the dependency. */ 00096 int latency; 00097 00098 /* The distance: number of loop iterations the dependency crosses. */ 00099 int distance; 00100 00101 /* The following two fields are used to form a linked list of the in/out 00102 going edges to/from each node. */ 00103 ddg_edge_ptr next_in; 00104 ddg_edge_ptr next_out; 00105 00106 /* For general use by algorithms manipulating the ddg. */ 00107 union { 00108 int count; 00109 void *info; 00110 } aux; 00111 }; 00112 00113 /* This structure holds the Data Dependence Graph for a basic block. */ 00114 struct ddg 00115 { 00116 /* The basic block for which this DDG is built. */ 00117 basic_block bb; 00118 00119 /* Number of instructions in the basic block. */ 00120 int num_nodes; 00121 00122 /* Number of load/store instructions in the BB - statistics. */ 00123 int num_loads; 00124 int num_stores; 00125 00126 /* This array holds the nodes in the graph; it is indexed by the node 00127 cuid, which follows the order of the instructions in the BB. */ 00128 ddg_node_ptr nodes; 00129 00130 /* The branch closing the loop. */ 00131 ddg_node_ptr closing_branch; 00132 00133 /* Build dependence edges for closing_branch, when set. In certain cases, 00134 the closing branch can be dealt with separately from the insns of the 00135 loop, and then no such deps are needed. */ 00136 int closing_branch_deps; 00137 00138 /* Array and number of backarcs (edges with distance > 0) in the DDG. */ 00139 ddg_edge_ptr *backarcs; 00140 int num_backarcs; 00141 }; 00142 00143 00144 /* Holds information on an SCC (Strongly Connected Component) of the DDG. */ 00145 struct ddg_scc 00146 { 00147 /* A bitmap that represents the nodes of the DDG that are in the SCC. */ 00148 sbitmap nodes; 00149 00150 /* Array and number of backarcs (edges with distance > 0) in the SCC. */ 00151 ddg_edge_ptr *backarcs; 00152 int num_backarcs; 00153 00154 /* The maximum of (total_latency/total_distance) over all cycles in SCC. */ 00155 int recurrence_length; 00156 }; 00157 00158 /* This structure holds the SCCs of the DDG. */ 00159 struct ddg_all_sccs 00160 { 00161 /* Array that holds the SCCs in the DDG, and their number. */ 00162 ddg_scc_ptr *sccs; 00163 int num_sccs; 00164 00165 ddg_ptr ddg; 00166 }; 00167 00168 00169 ddg_ptr create_ddg (basic_block, struct df *, int closing_branch_deps); 00170 void free_ddg (ddg_ptr); 00171 00172 void print_ddg (FILE *, ddg_ptr); 00173 void vcg_print_ddg (FILE *, ddg_ptr); 00174 void print_ddg_edge (FILE *, ddg_edge_ptr); 00175 00176 ddg_node_ptr get_node_of_insn (ddg_ptr, rtx); 00177 00178 void find_successors (sbitmap result, ddg_ptr, sbitmap); 00179 void find_predecessors (sbitmap result, ddg_ptr, sbitmap); 00180 00181 ddg_all_sccs_ptr create_ddg_all_sccs (ddg_ptr); 00182 void free_ddg_all_sccs (ddg_all_sccs_ptr); 00183 00184 int find_nodes_on_paths (sbitmap result, ddg_ptr, sbitmap from, sbitmap to); 00185 int longest_simple_path (ddg_ptr, int from, int to, sbitmap via); 00186 00187 #endif /* GCC_DDG_H */
1.5.6