update pet for support for recent versions of clang
[ppn.git] / dump_dependences.cc
blob9e6fb88c2e15f3cdaf170164c7f1e178ef98b427
1 #include <isl/map.h>
3 #include <isa/yaml.h>
4 #include <isa/pdg.h>
6 using namespace pdg;
8 int main(int argc, char * argv[])
10 PDG *pdg;
11 isl_ctx *ctx = isl_ctx_alloc();
12 isl_printer *p;
13 pdg = PDG::Load(stdin, ctx);
15 p = isl_printer_to_file(ctx, stdout);
17 for (int i = 0; i < pdg->dependences.size(); ++i) {
18 pdg::dependence *dep = pdg->dependences[i];
19 if (dep->type != pdg::dependence::uninitialized)
20 continue;
21 pdg::node* to = dep->to;
22 int to_access = dep->to_access ? dep->to_access->nr : -1;
23 const char *to_f = to->statement->top_function ?
24 to->statement->top_function->name->s.c_str() : "(none)";
25 pdg::IslMap *rel = dep->relation;
26 isl_map *map = rel->get_isl_map(ctx);
27 p = isl_printer_print_str(p, dep->array->name->s.c_str());
28 p = isl_printer_print_str(p, " uninitialized at ");
29 p = isl_printer_print_int(p, to->nr);
30 p = isl_printer_print_str(p, ",");
31 p = isl_printer_print_int(p, to_access);
32 p = isl_printer_print_str(p, " (");
33 p = isl_printer_print_str(p, to_f);
34 p = isl_printer_print_str(p, ",line ");
35 p = isl_printer_print_int(p, to->statement->line);
36 p = isl_printer_print_str(p, "): ");
37 p = isl_printer_print_map(p, map);
38 p = isl_printer_end_line(p);
39 isl_map_free(map);
42 for (int i = 0; i < pdg->dependences.size(); ++i) {
43 pdg::dependence *dep = pdg->dependences[i];
44 if (dep->type == pdg::dependence::uninitialized)
45 continue;
46 pdg::node* from = dep->from;
47 pdg::node* to = dep->to;
48 int from_access = dep->from_access ? dep->from_access->nr : -1;
49 int to_access = dep->to_access ? dep->to_access->nr : -1;
50 const char *from_f = from->statement->top_function ?
51 from->statement->top_function->name->s.c_str() :
52 "(none)";
53 const char *to_f = to->statement->top_function ?
54 to->statement->top_function->name->s.c_str() : "(none)";
55 pdg::IslMap *rel = dep->relation;
56 isl_map *map = rel->get_isl_map(ctx);
57 p = isl_printer_print_str(p, "type: ");
58 p = isl_printer_print_int(p, dep->type);
59 p = isl_printer_end_line(p);
60 p = isl_printer_print_int(p, from->nr);
61 p = isl_printer_print_str(p, ",");
62 p = isl_printer_print_int(p, from_access);
63 p = isl_printer_print_str(p, " (");
64 p = isl_printer_print_str(p, from_f);
65 p = isl_printer_print_str(p, ",line ");
66 p = isl_printer_print_int(p, from->statement->line);
67 p = isl_printer_print_str(p, ") --(");
68 if (dep->array)
69 p = isl_printer_print_str(p, dep->array->name->s.c_str());
70 for (int j = 0; j < dep->from_controls.size(); ++j) {
71 if (j)
72 p = isl_printer_print_str(p, ",");
73 p = isl_printer_print_str(p, dep->from_controls[j]->s.c_str());
75 for (int j = 0; j < dep->to_controls.size(); ++j) {
76 if (j)
77 p = isl_printer_print_str(p, ",");
78 else
79 p = isl_printer_print_str(p, "; ");
80 p = isl_printer_print_str(p, dep->to_controls[j]->s.c_str());
82 p = isl_printer_print_str(p, ")--> ");
83 p = isl_printer_print_int(p, to->nr);
84 p = isl_printer_print_str(p, ",");
85 p = isl_printer_print_int(p, to_access);
86 p = isl_printer_print_str(p, " (");
87 p = isl_printer_print_str(p, to_f);
88 p = isl_printer_print_str(p, ",line ");
89 p = isl_printer_print_int(p, to->statement->line);
90 p = isl_printer_print_str(p, "): ");
91 p = isl_printer_print_map(p, map);
92 p = isl_printer_end_line(p);
93 isl_map_free(map);
94 if (dep->extended_relation) {
95 pdg::IslMap *rel = dep->extended_relation;
96 isl_map *map = rel->get_isl_map(ctx);
97 p = isl_printer_print_str(p, "extended: ");
98 p = isl_printer_print_map(p, map);
99 p = isl_printer_end_line(p);
100 isl_map_free(map);
102 if (dep->controlled_relation) {
103 isl_map *map = dep->controlled_relation->map;
104 p = isl_printer_print_str(p, "controlled: ");
105 p = isl_printer_print_map(p, map);
106 p = isl_printer_end_line(p);
110 pdg->free();
111 delete pdg;
112 isl_printer_free(p);
113 isl_ctx_free(ctx);
115 return 0;