1 #ifndef DEPENDENCE_GRAPH_H
2 #define DEPENDENCE_GRAPH_H
20 edge() : type(normal
) { }
22 isl_map_free(relation
);
30 const char *operation
;
35 unsigned is_expanded
: 1;
36 computation
*original
;
38 std::vector
<edge
*> edges
;
40 computation() : input(0), is_expanded(0), original(NULL
), dim(-1) {}
43 for (int i
= 0; i
< edges
.size(); ++i
)
46 free((char *)operation
);
49 bool has_same_source(computation
*other
) const {
52 if (this->original
== other
)
54 if (this == other
->original
)
56 if (this->original
&& this->original
== other
->original
)
61 bool is_input() const {
65 bool is_copy() const {
66 return !input
&& !is_expanded
&&
67 !strcmp(operation
, "") && arity
== 1;
73 struct input_array
: computation
{
74 input_array(const char *name
, __isl_take isl_space
*dims
) {
75 dim
= isl_space_dim(dims
, isl_dim_set
);
77 dims
= isl_space_set_tuple_name(dims
,
79 domain
= isl_set_universe(dims
);
80 operation
= strdup(name
);
87 struct dependence_graph
{
89 std::vector
<char *> output_arrays
;
90 std::vector
<unsigned> output_array_dims
;
91 std::vector
<computation
*> vertices
;
92 std::vector
<computation
*> input_computations
;
95 dependence_graph() : out(NULL
), context(NULL
) {}
97 isl_set_free(context
);
98 for (int i
= 0; i
< output_arrays
.size(); ++i
)
99 free(output_arrays
[i
]);
100 for (int i
= 0; i
< vertices
.size(); ++i
)
105 void splice(computation
*comp
, edge
*e
);
106 computation
*split_comp(computation
*comp
, edge
*e
);
107 void split_edges(computation
*comp_orig
, computation
*comp_dup
);
108 void split_edges(computation
*comp
,
109 computation
*comp_orig
, computation
*comp_dup
);
110 computation
*associative_node(edge
**e
,
111 const std::vector
<const char *> &associative
);
112 void flatten_associative_operators(
113 const std::vector
<const char *> &associative
);
117 dependence_graph
*pdg_to_dg(pdg::PDG
*pdg
, unsigned out_dim
,
118 __isl_take isl_set
*context
);