handle "live-out" pragmas
[pet.git] / scop_plus.cc
blob490bf6c03851ebd95329968869cda891051ea683
1 #include <set>
3 #include "scop_plus.h"
5 using namespace std;
6 using namespace clang;
8 static void access_collect_arrays(struct pet_expr *expr,
9 set<ValueDecl *> &arrays)
11 isl_id *id;
12 ValueDecl *decl;
14 id = isl_map_get_tuple_id(expr->acc.access, isl_dim_out);
15 if (!id)
16 return;
18 decl = (ValueDecl *)isl_id_get_user(id);
19 isl_id_free(id);
21 arrays.insert(decl);
24 static void expr_collect_arrays(struct pet_expr *expr, set<ValueDecl *> &arrays)
26 if (!expr)
27 return;
29 for (int i = 0; i < expr->n_arg; ++i)
30 expr_collect_arrays(expr->args[i], arrays);
32 if (expr->type == pet_expr_access)
33 access_collect_arrays(expr, arrays);
36 static void stmt_collect_arrays(struct pet_stmt *stmt, set<ValueDecl *> &arrays)
38 if (!stmt)
39 return;
40 expr_collect_arrays(stmt->body, arrays);
43 /* Collect the set of all accessed arrays (or scalars) in "scop"
44 * and put them in "arrays".
46 void pet_scop_collect_arrays(struct pet_scop *scop, set<ValueDecl *> &arrays)
48 if (!scop)
49 return;
51 for (int i = 0; i < scop->n_stmt; ++i)
52 stmt_collect_arrays(scop->stmts[i], arrays);