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