]>
Commit | Line | Data |
---|---|---|
d397e8c6 MH |
1 | /* DDG - Data Dependence Graph - interface. |
2 | Copyright (C) 2004 | |
3 | Free Software Foundation, Inc. | |
4 | Contributed by Ayal Zaks and Mustafa Hagog <zaks,mustafa@il.ibm.com> | |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
10 | Software Foundation; either version 2, or (at your option) any later | |
11 | version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GCC; see the file COPYING. If not, write to the Free | |
20 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
21 | 02111-1307, USA. */ | |
22 | ||
23 | #ifndef GCC_DDG_H | |
24 | #define GCC_DDG_H | |
25 | ||
26 | ||
27 | typedef struct ddg_node *ddg_node_ptr; | |
28 | typedef struct ddg_edge *ddg_edge_ptr; | |
29 | typedef struct ddg *ddg_ptr; | |
30 | typedef struct ddg_scc *ddg_scc_ptr; | |
31 | typedef struct ddg_all_sccs *ddg_all_sccs_ptr; | |
32 | ||
33 | typedef enum {TRUE_DEP, OUTPUT_DEP, ANTI_DEP} dep_type; | |
34 | typedef enum {REG_OR_MEM_DEP, REG_DEP, MEM_DEP, REG_AND_MEM_DEP} | |
35 | dep_data_type; | |
36 | ||
37 | /* The following two macros enables direct access to the successors and | |
38 | predecessors bitmaps held in each ddg_node. Do not make changes to | |
39 | these bitmaps, unless you want to change the DDG. */ | |
40 | #define NODE_SUCCESSORS(x) ((x)->successors) | |
41 | #define NODE_PREDECESSORS(x) ((x)->predecessors) | |
42 | ||
43 | /* A structure that represents a node in the DDG. */ | |
44 | struct ddg_node | |
45 | { | |
46 | /* Each node has a unique CUID index. These indices increase monotonically | |
47 | (according to the order of the corresponding INSN in the BB), starting | |
48 | from 0 with no gaps. */ | |
49 | int cuid; | |
50 | ||
51 | /* The insn represented by the node. */ | |
52 | rtx insn; | |
53 | ||
1ea7e6ad | 54 | /* A note preceding INSN (or INSN itself), such that all insns linked |
d397e8c6 MH |
55 | from FIRST_NOTE until INSN (inclusive of both) are moved together |
56 | when reordering the insns. This takes care of notes that should | |
1ea7e6ad | 57 | continue to precede INSN. */ |
d397e8c6 MH |
58 | rtx first_note; |
59 | ||
60 | /* Incoming and outgoing dependency edges. */ | |
61 | ddg_edge_ptr in; | |
62 | ddg_edge_ptr out; | |
63 | ||
64 | /* Each bit corresponds to a ddg_node according to its cuid, and is | |
65 | set iff the node is a successor/predecessor of "this" node. */ | |
66 | sbitmap successors; | |
67 | sbitmap predecessors; | |
68 | ||
69 | /* For general use by algorithms manipulating the ddg. */ | |
70 | union { | |
71 | int count; | |
72 | void *info; | |
73 | } aux; | |
74 | }; | |
75 | ||
76 | /* A structure that represents an edge in the DDG. */ | |
77 | struct ddg_edge | |
78 | { | |
79 | /* The source and destination nodes of the dependency edge. */ | |
80 | ddg_node_ptr src; | |
81 | ddg_node_ptr dest; | |
82 | ||
83 | /* TRUE, OUTPUT or ANTI dependency. */ | |
84 | dep_type type; | |
85 | ||
86 | /* REG or MEM dependency. */ | |
87 | dep_data_type data_type; | |
88 | ||
89 | /* Latency of the depedency. */ | |
90 | int latency; | |
91 | ||
92 | /* The distance: number of loop iterations the dependency crosses. */ | |
93 | int distance; | |
94 | ||
95 | /* The following two fields are used to form a linked list of the in/out | |
96 | going edges to/from each node. */ | |
97 | ddg_edge_ptr next_in; | |
98 | ddg_edge_ptr next_out; | |
99 | ||
100 | /* For general use by algorithms manipulating the ddg. */ | |
101 | union { | |
102 | int count; | |
103 | void *info; | |
104 | } aux; | |
105 | }; | |
106 | ||
107 | /* This structure holds the Data Dependence Graph for a basic block. */ | |
108 | struct ddg | |
109 | { | |
110 | /* The basic block for which this DDG is built. */ | |
111 | basic_block bb; | |
112 | ||
113 | /* Number of instructions in the basic block. */ | |
114 | int num_nodes; | |
115 | ||
116 | /* Number of load/store instructions in the BB - statistics. */ | |
117 | int num_loads; | |
118 | int num_stores; | |
119 | ||
120 | /* This array holds the nodes in the graph; it is indexed by the node | |
121 | cuid, which follows the order of the instructions in the BB. */ | |
122 | ddg_node_ptr nodes; | |
123 | ||
124 | /* The branch closing the loop. */ | |
125 | ddg_node_ptr closing_branch; | |
126 | ||
127 | /* Build dependence edges for closing_branch, when set. In certain cases, | |
128 | the closing branch can be dealt with separately from the insns of the | |
129 | loop, and then no such deps are needed. */ | |
130 | int closing_branch_deps; | |
131 | ||
132 | /* Array and number of backarcs (edges with distance > 0) in the DDG. */ | |
133 | ddg_edge_ptr *backarcs; | |
134 | int num_backarcs; | |
135 | }; | |
136 | ||
137 | \f | |
138 | /* Holds information on an SCC (Strongly Connected Component) of the DDG. */ | |
139 | struct ddg_scc | |
140 | { | |
141 | /* A bitmap that represents the nodes of the DDG that are in the SCC. */ | |
142 | sbitmap nodes; | |
143 | ||
144 | /* Array and number of backarcs (edges with distance > 0) in the SCC. */ | |
145 | ddg_edge_ptr *backarcs; | |
146 | int num_backarcs; | |
147 | ||
148 | /* The maximum of (total_latency/total_distance) over all cycles in SCC. */ | |
149 | int recurrence_length; | |
150 | }; | |
151 | ||
152 | /* This structure holds the SCCs of the DDG. */ | |
153 | struct ddg_all_sccs | |
154 | { | |
155 | /* Array that holds the SCCs in the DDG, and their number. */ | |
156 | ddg_scc_ptr *sccs; | |
157 | int num_sccs; | |
158 | ||
159 | ddg_ptr ddg; | |
160 | }; | |
161 | ||
162 | \f | |
163 | ddg_ptr create_ddg (basic_block, struct df *, int closing_branch_deps); | |
164 | void free_ddg (ddg_ptr); | |
165 | ||
166 | void print_ddg (FILE *, ddg_ptr); | |
167 | void vcg_print_ddg (FILE *, ddg_ptr); | |
168 | void print_ddg_edge (FILE *, ddg_edge_ptr); | |
169 | ||
170 | ddg_node_ptr get_node_of_insn (ddg_ptr, rtx); | |
171 | ||
172 | void find_successors (sbitmap result, ddg_ptr, sbitmap); | |
173 | void find_predecessors (sbitmap result, ddg_ptr, sbitmap); | |
174 | ||
175 | ddg_all_sccs_ptr create_ddg_all_sccs (ddg_ptr); | |
176 | void free_ddg_all_sccs (ddg_all_sccs_ptr); | |
177 | ||
178 | int find_nodes_on_paths (sbitmap result, ddg_ptr, sbitmap from, sbitmap to); | |
179 | int longest_simple_path (ddg_ptr, int from, int to, sbitmap via); | |
180 | ||
181 | #endif /* GCC_DDG_H */ |