13 /* Represents a (possibly indexed) variable of a certain type.
15 * "expr" contains a pointer to an allocated buffer created by get_expr().
18 isl_pw_multi_aff
*access
;
21 adg_var() : access(NULL
), type(NULL
), expr(NULL
) {}
22 adg_var(const adg_var
&var
) : expr(NULL
) {
23 access
= isl_pw_multi_aff_copy(var
.access
);
24 type
= isl_id_copy(var
.type
);
27 isl_pw_multi_aff_free(access
);
32 __isl_keep
const char *get_expr();
33 void print(FILE *out
= stdout
);
34 int print(yaml_emitter_t
*emitter
);
35 int is_equal(adg_var
*var2
);
40 /* Represents a named piecewise affine expression.
46 adg_expr() : name(NULL
), expr(NULL
) {}
47 adg_expr(const adg_expr
©
) {
48 name
= isl_id_copy(copy
.name
);
49 expr
= isl_pw_aff_copy(copy
.expr
);
53 isl_pw_aff_free(expr
);
56 int print(yaml_emitter_t
*emitter
);
57 int is_equal(adg_expr
*expr2
);
60 /* Represents a domain. The set "bounds" should have no existentially
61 * quantified variables. Instead, the domain may be nested (possibly
62 * multiple times) with extra control variables in the "local" output
63 * of the nested map. Each of these extra variables is represented
64 * by an adg_expr in the controls vector.
65 * Additionally, the domain may also be nested with extra filter
66 * variables in the input of the nested map. Each of these filters
67 * is represented by an adg_var in the filters vector.
68 * The different types of nestings may be interleaved.
72 std::vector
<adg_expr
*> controls
;
73 std::vector
<adg_var
*> filters
;
75 adg_domain() : bounds(NULL
) {}
76 adg_domain(__isl_take isl_set
*bounds
) : bounds(bounds
) {}
78 for (int i
= 0; i
< controls
.size(); ++i
)
80 for (int i
= 0; i
< filters
.size(); ++i
)
85 int print(yaml_emitter_t
*emitter
);
86 int is_equal(adg_domain
*domain2
);
89 /* Represents a port with a name, belonging to a node called node_name
90 * and connected to an edge called edge_name.
91 * For each iteration in "domain" each of adg_vars in "vars"
92 * is either read from the edge or written to the edge.
94 * edge_nr is the number of the (non-control) edge to which
95 * port is connected or related.
96 * arg_pos reflects the argument position of the variable accessed
103 std::vector
<adg_var
*> vars
;
108 adg_port() : name(NULL
), node_name(NULL
), edge_name(NULL
),
109 domain(NULL
), edge_nr(-1), arg_pos(-1) {}
112 isl_id_free(node_name
);
113 isl_id_free(edge_name
);
114 for (int i
= 0; i
< vars
.size(); ++i
)
119 int print(yaml_emitter_t
*emitter
);
120 int is_equal(adg_port
*port2
);
123 /* Represents a gate called "name", belonging to a node calles "node_name"
124 * that copies the value of "in" to "out" for each iteration in "domain".
133 adg_gate() : name(NULL
), node_name(NULL
),
134 in(NULL
), out(NULL
), domain(NULL
) {}
137 isl_id_free(node_name
);
143 int print(yaml_emitter_t
*emitter
);
144 int is_equal(adg_gate
*gate2
);
154 /* Represents an argument to a function.
155 * It contains the variable that is read or written and the way
156 * it is passed to/from the function.
160 enum adg_arg_type type
;
162 adg_arg() : var(NULL
), type(adg_arg_unknown
) {}
167 int print(yaml_emitter_t
*emitter
);
168 int is_equal(adg_arg
*arg2
);
171 /* Represents the execution of a function called "name" for each
172 * iteration of "domain".
173 * The "ctrl" vector contains references to variables that should
174 * be written on each iteration of the function. The value that
175 * should be written is given by the expr field of the adg_expr.
177 struct adg_function
{
181 std::vector
<adg_arg
*> in
;
182 std::vector
<adg_arg
*> out
;
183 std::vector
<adg_expr
*> ctrl
;
185 adg_function() : name(NULL
), domain(NULL
) {}
189 for (int i
= 0; i
< in
.size(); ++i
)
191 for (int i
= 0; i
< out
.size(); ++i
)
193 for (int i
= 0; i
< ctrl
.size(); ++i
)
197 int print(yaml_emitter_t
*emitter
);
198 int is_equal(adg_function
*function2
);
203 adg_edge_sticky_fifo
,
204 adg_edge_shift_register
,
210 /* Represents an edge called "name" connecting the port "from_port_name"
211 * in node "from_node_name" to the port "to_port_name" in node "to_node_name".
213 * "map" maps an iteration of the "to_port_name" to the corresponding
214 * iteration of the "from_port_name", i.e., to the iteration that wrote
215 * the values that is being read in the given iteration.
217 * If each parameter is assigned its "val" values, then a buffer size
218 * of "value_size" on this edge is sufficient to allow for a deadlock
223 isl_id
*from_node_name
;
224 isl_id
*from_port_name
;
225 isl_id
*to_node_name
;
226 isl_id
*to_port_name
;
228 enum adg_edge_type type
;
233 adg_edge() : name(NULL
), from_node_name(NULL
), from_port_name(NULL
),
234 to_node_name(NULL
), to_port_name(NULL
), map(NULL
),
235 value_size(NULL
), type(adg_edge_fifo
) { }
238 isl_id_free(from_node_name
);
239 isl_id_free(from_port_name
);
240 isl_id_free(to_node_name
);
241 isl_id_free(to_port_name
);
242 isl_multi_aff_free(map
);
243 isl_val_free(value_size
);
246 int print(yaml_emitter_t
*emitter
);
247 int is_equal(adg_edge
*edge2
);
250 /* Represents a node called "name" with input ports, gates, expressions,
251 * output ports and function.
253 * "domain" is the iteration domain.
254 * "schedule" is the schedule for this node.
255 * "lifting" is a mapping that has been used to remove
256 * existentially quantified from the domain of this node and that
257 * should be applied to the domains of the subelements to ensure
258 * that they have the same initial (static) control variables.
263 std::vector
<adg_port
*> input_ports
;
264 std::vector
<adg_gate
*> gates
;
265 std::vector
<adg_expr
*> expressions
;
266 std::vector
<adg_port
*> output_ports
;
268 adg_function
*function
;
272 isl_basic_map
*lifting
;
274 adg_node() : name(NULL
), function(NULL
), domain(NULL
), schedule(NULL
),
278 for (int i
= 0; i
< input_ports
.size(); ++i
)
279 delete input_ports
[i
];
280 for (int i
= 0; i
< gates
.size(); ++i
)
282 for (int i
= 0; i
< expressions
.size(); ++i
)
283 delete expressions
[i
];
284 for (int i
= 0; i
< output_ports
.size(); ++i
)
285 delete output_ports
[i
];
288 isl_map_free(schedule
);
289 isl_basic_map_free(lifting
);
292 int print(yaml_emitter_t
*emitter
);
293 int is_equal(adg_node
*node2
);
296 /* Represents a parameters called "name" with lower bound "lb", upper
297 * bound "ub" and default value "val".
305 adg_param() : name(NULL
), lb(NULL
), ub(NULL
), val(NULL
) {}
313 int print(yaml_emitter_t
*emitter
);
314 int is_equal(adg_param
*param2
);
317 /* Represents an approximate dependence graph called "name", with parameters,
320 * "context" represents the constraints on the parameters.
321 * "iterators" represents the iterators used in the domains of the adg.
322 * "all_iterators" represents the iterators used in the schedules of the adg.
323 * "iterator_map" maps (some) elements of "all_iterators" to the
324 * corresponding element in "iterators".
325 * "controls" collects all static control variables so that we can
326 * reuse them in to_control.
331 isl_map
*iterator_map
;
333 std::vector
<adg_param
*> params
;
334 std::vector
<adg_node
*> nodes
;
335 std::vector
<adg_edge
*> edges
;
336 std::vector
<isl_id
*> iterators
;
337 std::vector
<isl_id
*> all_iterators
;
338 std::vector
<adg_expr
*> controls
;
340 adg() : name(NULL
), context(NULL
), iterator_map(NULL
) {}
343 isl_set_free(context
);
344 isl_map_free(iterator_map
);
345 for (int i
= 0; i
< params
.size(); ++i
)
347 for (int i
= 0; i
< nodes
.size(); ++i
)
349 for (int i
= 0; i
< edges
.size(); ++i
)
351 for (int i
= 0; i
< all_iterators
.size(); ++i
)
352 isl_id_free(all_iterators
[i
]);
353 for (int i
= 0; i
< iterators
.size(); ++i
)
354 isl_id_free(iterators
[i
]);
355 for (int i
= 0; i
< controls
.size(); ++i
)
358 adg_node
*node_by_id(__isl_keep isl_id
*id
);
359 void print(FILE *out
= stdout
);
360 int print(yaml_emitter_t
*emitter
);
361 int is_equal(adg
*adg2
);
362 adg_expr
*to_control(__isl_take isl_aff
*expr
);