update barvinok to version 0.41.7
[ppn.git] / tests / da.cc
blob3b99ae77a81e8f2bfc032db414ef7b8574d3d9a8
1 #include <assert.h>
2 #include "testlib.h"
4 using pdg::PDG;
6 #ifdef HAVE_PET
7 #define CHECK_DATA_DEPENDENT 1
8 #else
9 #define CHECK_DATA_DEPENDENT 0
10 #endif
12 /* Check that the dependence(s) between "from" and "to" are parametric
13 * (if controlled is true) or not parametric (if controlled is false).
15 static void check_controlled(PDG *pdg, const char *from, const char *to,
16 bool controlled)
18 for (int i = 0; i < pdg->dependences.size(); ++i) {
19 pdg::dependence *dep = pdg->dependences[i];
21 if (dep->from->name->s != from)
22 continue;
23 if (dep->to->name->s != to)
24 continue;
25 if (controlled)
26 assert(dep->controlled_relation);
27 else
28 assert(!dep->controlled_relation);
32 /* Check the results of parametric dataflow analysis
33 * on a variation of example E1 from Barthou's PhD text, page 100.
35 * We expect the dependences between S1 and S2 to be non-parametric,
36 * while those with R as sink should be parametric.
38 static void check_barthou_E1(isl_ctx *ctx)
40 PDG *pdg;
42 construct_pdg("barthou_E1");
43 pdg = get_da(ctx, "barthou_E1");
45 assert(pdg->nodes.size() == 4);
46 assert(pdg->dependences.size() == 6);
48 check_controlled(pdg, "S1", "S2", false);
49 check_controlled(pdg, "S2", "S2", false);
50 check_controlled(pdg, "S1", "R", true);
51 check_controlled(pdg, "S2", "R", true);
53 pdg->free();
54 delete pdg;
57 int main(int argc, char *argv[])
59 isl_ctx *ctx = isl_ctx_alloc();
60 construct_pdg("testindex2");
61 PDG *pdg = get_da(ctx, "testindex2", "-t flow,anti");
63 assert(pdg->nodes.size() == 3);
64 assert(pdg->dependences.size() == 3);
66 pdg->free();
67 delete pdg;
69 if (CHECK_DATA_DEPENDENT)
70 check_barthou_E1(ctx);
72 isl_ctx_free(ctx);
74 return 0;