1 #ifndef DEPENDENCE_GRAPH_H
2 #define DEPENDENCE_GRAPH_H
21 edge() : type(normal
) { }
23 isl_map_free(relation
);
31 const char *operation
;
36 unsigned is_expanded
: 1;
37 computation
*original
;
39 std::vector
<edge
*> edges
;
41 computation() : input(0), is_expanded(0), original(NULL
), dim(-1) {}
44 for (int i
= 0; i
< edges
.size(); ++i
)
47 free((char *)operation
);
50 bool has_same_source(computation
*other
) const {
53 if (this->original
== other
)
55 if (this == other
->original
)
57 if (this->original
&& this->original
== other
->original
)
62 bool is_input() const {
66 bool is_copy() const {
67 return !input
&& !is_expanded
&&
68 !strcmp(operation
, "") && arity
== 1;
74 struct input_array
: computation
{
75 input_array(const char *name
, __isl_take isl_space
*dims
) {
76 dim
= isl_space_dim(dims
, isl_dim_set
);
78 dims
= isl_space_set_tuple_name(dims
,
80 domain
= isl_set_universe(dims
);
81 operation
= strdup(name
);
88 struct dependence_graph
{
90 std::vector
<char *> output_arrays
;
91 std::vector
<unsigned> output_array_dims
;
92 std::vector
<computation
*> vertices
;
93 std::vector
<computation
*> input_computations
;
96 dependence_graph() : out(NULL
), context(NULL
) {}
98 isl_set_free(context
);
99 for (int i
= 0; i
< output_arrays
.size(); ++i
)
100 free(output_arrays
[i
]);
101 for (int i
= 0; i
< vertices
.size(); ++i
)
106 void splice(computation
*comp
, edge
*e
);
107 computation
*split_comp(computation
*comp
, edge
*e
);
108 void split_edges(computation
*comp_orig
, computation
*comp_dup
);
109 void split_edges(computation
*comp
,
110 computation
*comp_orig
, computation
*comp_dup
);
111 computation
*associative_node(edge
**e
,
112 const std::vector
<const char *> &associative
);
113 void flatten_associative_operators(
114 const std::vector
<const char *> &associative
);
118 dependence_graph
*pdg_to_dg(pdg::PDG
*pdg
, unsigned out_dim
,
119 __isl_take isl_set
*context
);